sqlalchemy
系统的学一下sqlalchemyA,不过没有中文文档,只能用我的渣英文能力慢慢看原文档了
数据库连接
>>> from sqlalchemy import create_engine
>>> engine = create_engine('sqlite:///:memory:', echo=True)
echo为True输出日志
各种数据库连接方式
dialect+driver://username:password@host:port/database
-
Postgresql
# default engine = create_engine('postgresql://scott:tiger@localhost/mydatabase') # psycopg2 engine = create_engine('postgresql+psycopg2://scott:tiger@localhost/mydatabase') # pg8000 engine = create_engine('postgresql+pg8000://scott:tiger@localhost/mydatabase')
-
MySQL
# default engine = create_engine('mysql://scott:tiger@localhost/foo') # mysql-python engine = create_engine('mysql …