首页 > psycopg2和sqlalchemy的区别是啥?

psycopg2和sqlalchemy的区别是啥?

sqlalchemy可以连接postgresql,而且还支持ORM.
那么psycopg2的优势什么?


sqlalchemy的官网介绍:

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是号称可以搞定很多SQL,包括但不仅仅是PostgreSQL, 事实上很多python操作数据库的教程大都是用sqlalchemysqlite的组合,可以算是全能型选手,有点像瑞士军刀的节奏。

psycopg2则是专门就搞PostgreSQL,他的优势就在于它是专搞PostgreSQL,所以对PostgreSQL的一些特性支持会更好,也是PostgreSQL官方指定推荐的python driver,对于PostgreSQL这颗西瓜来说他就是最合适的西瓜刀。

实际上项目但凡决定用PostgreSQL的自然而然就会想到psycopg2而不会去考虑sqlalchemy

【热门文章】
【热门文章】