python - psycopg2和sqlalchemy的区别是啥?
迷茫
迷茫 2017-04-18 09:27:04
[Python讨论组]

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

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

全部回复(1)
天蓬老师

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

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号