Skip to main content

Enmotech MogDB Dialect for SQLAlchemy

Project description

sqlalchemy-mogdb

Enmotech MogDB 数据库适配 SQLAlchemy 的连接器.

前置工作

在使用 sqlalchemy-mogdb 之前,需要提前安装适用于 MogDB 数据库的 psycopg2 驱动才能正常工作。

安装方式:

  1. 软件下载:

    openEuler-aarch64: openGauss-3.0.0-openEuler-aarch64-Python.tar.gz

    CentOS-x86_64: openGauss-3.0.0-CentOS-x86_64-Python.tar.gz

    openEuler-x86_64: openGauss-3.0.0-openEuler-x86_64-Python.tar.gz

  2. 解压安装包,得到两个目录 libpsycopg2

  3. 安装 将 psycopg2 文件夹整个拷贝到你对应的 python 解释器的 site-packages 目录下

    查找 site-packages 目录所在位置的方式,在终端执行下面的代码(注意你要找的是 python3 的话,使用 python3 执行):

    python -c "from distutils.sysconfig import get_python_lib;print(get_python_lib())"
    # output: /usr/lib/python3.7/site-packages
    

    拷贝方式:

    cp -r psycopg2 [/path/to/site-packages/]
    

    修改包的权限,允许其他用户引用

    chmod -R 755 [/path/to/site-packages/]psycopg2
    
  4. 设置 LD_LIBRARY_PATH 环境变量

    将解压后的 lib 目录放到任意目录,然后拷贝路径(假设存放位置为: /usr/local/share/psycopg2/lib

    设置环境变量:

    echo "export LD_LIBRARY_PATH=/usr/local/share/psycopg2/lib:$LD_LIBRARY_PATH" >> ~/.bashrc
    source ~/.bashrc
    

安装 sqlalchemy-mogdb

在线安装

该包可在PyPI上在线安装:

    pip install sqlalchemy-mogdb

安装完成后即可使用。

离线安装

  1. 安装 sqlalchemy

    下载对应系统版本的 whl 文件: https://github.com/sqlalchemy/sqlalchemy/releases

    下载后执行 pip 安装: pip install xxx.whl

  2. 安装 sqlalchemy_mogdb

    下载 sqlalchemy_mogdb 源码文件: https://pypi.org/project/sqlalchemy-mogdb/#files

    解压后进入源码目录,执行 python setup.py install

用法

DSN 格式与 Postgres 类似:

>>> import sqlalchemy as sa
>>> sa.create_engine('mogdb+psycopg2://username:password@ip:26000/database')
Engine(mogdb+psycopg2://username@ip:26000/database)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sqlalchemy-mogdb-0.1.2.tar.gz (79.9 kB view details)

Uploaded Source

File details

Details for the file sqlalchemy-mogdb-0.1.2.tar.gz.

File metadata

  • Download URL: sqlalchemy-mogdb-0.1.2.tar.gz
  • Upload date:
  • Size: 79.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.12

File hashes

Hashes for sqlalchemy-mogdb-0.1.2.tar.gz
Algorithm Hash digest
SHA256 678cb34ef847f3045f73b17a49eb7ba7e16067958094732590f819eaa3925523
MD5 f94dc3b2eb802739f559bc40ce68230f
BLAKE2b-256 a148f3f2c1cc0014f461982a60ae88c22520574c56240682a42c54b04b298ef0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page