SQLAlchemy is a ORM, psycopg2 is a database driver. These are completely different things: SQLAlchemy generates SQL statements and psycopg2 sends SQL statements to the database. SQLAlchemy depends on psycopg2 or other database drivers to communicate with the database!
As a rather complex software layer SQLAlchemy does add some overhead but it also is a huge boost to development speed, at least once you learned the library. SQLAlchemy is an excellent library and will teach you the whole ORM concept, but if you don't want to generate SQL statements to begin with then you don't want SQLAlchemy.
SQLAlchemy 是一個 ORM(物件關係對映),psycopg2 是一個資料庫驅動程式,這兩者是完全不同的東西。
SQLAlchemy 用於生成 SQL 語句
psycopg2 用於將 SQL 語句發送到資料庫
SQLAlchemy 依賴於 psycopg2 或其他資料庫驅動程式來與資料庫進行通訊!
作為一個相對複雜的軟體層,SQLAlchemy 確實增加了一些額外負擔,但它也大大提高了開發速度,至少在你學會這個庫之後是這樣的。SQLAlchemy 是一個優秀的庫,它會教會你整個 ORM 的概念,但如果你一開始就不想生成 SQL 語句,那麼你就不需要使用 SQLAlchemy。