Help Center/
GaussDB/
Developer Guide(Distributed_2.x)/
Application Development Guide/
Psycopg-based Development/
Loading a Driver
Updated on 2024-10-14 GMT+08:00
Loading a Driver
- Before using the driver, perform the following operations:
- Decompress the driver package of the corresponding version and copy psycopg2 to the site-packages folder in the Python installation directory as the root user.
tar zxvf xxxx-Python.tar.gz su root cp psycopg2 $(python3 -c 'import site; print(site.getsitepackages()[0])') -r
- Change the psycopg2 directory permission to 755.
chmod 755 $(python3 -c 'import site; print(site.getsitepackages()[0])')/psycopg2 -R
- Add the psycopg2 directory to the environment variable $PYTHONPATH and validate it.
export PYTHONPATH=$(python3 -c 'import site; print(site.getsitepackages()[0])'):$PYTHONPATH
- For non-database users, configure the lib directory in LD_LIBRARY_PATH after decompression.
export LD_LIBRARY_PATH=path/to/lib:$LD_LIBRARY_PATH
- Decompress the driver package of the corresponding version and copy psycopg2 to the site-packages folder in the Python installation directory as the root user.
- Load the database driver before creating a database connection.
import psycopg2
Parent topic: Psycopg-based Development
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
The system is busy. Please try again later.
For any further questions, feel free to contact us through the chatbot.
Chatbot