在mysql或postgresql中使用sql的帮助函数和工具
sql-helper的Python项目详细描述
关于
这是一种探索postgresql/mysql数据库的简单方法 并获取数据(sqlalchemy的超轻包装)。
以以下格式连接数据库URL:
postgresql://someuser:somepassword@somehost/somedatabase
mysql://someuser:somepassword@somehost/somedatabase
Note: This package uses ^{tt3}$ driver for connecting to mysql. Urls that start with ^{tt4}$ will automatically be changed to use ^{tt5}$.
安装
$ pip3 install sql-helper
用法
In [1]: from sql_helper import SQL In [2]: sql = SQL('postgresql://someuser:somepassword@somehost/somedatabase') In [3]: table_names = sql.get_tables() In [4]: results = sql.execute('SELECT ...')
额外
Redshift
Ensure the ^{tt6}$ executable is on the system
$ sudo apt-get install -y libpq-dev or $ brew install postgresql
然后在安装的任何位置安装sqlalchemy-redshift。 sql-helper
$ venv/bin/pip3 install sqlalchemy-redshift
以以下格式连接数据库URL:
- redshift+psycopg2://someuser:somepassword@somehost/somedatabase