SQLAlchemy is the Python SQL toolkit and Object Relational Mapper that gives application developers the full power and flexibility of SQL.
psycopg2的官网介绍:
Psycopg is the most popular PostgreSQL adapter for the Python programming language. At its core it fully implements the Python DB API 2.0 specifications. Several extensions allow access to many of the features offered by PostgreSQL.
sqlalchemy
的官网介绍:psycopg2
的官网介绍:sqlalchemy
是号称可以搞定很多SQL
,包括但不仅仅是PostgreSQL
, 事实上很多python
操作数据库的教程大都是用sqlalchemy
加sqlite
的组合,可以算是全能型选手,有点像瑞士军刀的节奏。psycopg2
则是专门就搞PostgreSQL
,他的优势就在于它是专搞PostgreSQL
,所以对PostgreSQL
的一些特性支持会更好,也是PostgreSQL
官方指定推荐的python driver
,对于PostgreSQL
这颗西瓜来说他就是最合适的西瓜刀。实际上项目但凡决定用
PostgreSQL
的自然而然就会想到psycopg2
而不会去考虑sqlalchemy