Reputation: 2237
Do I need SQLAlchemy if I want to use PostgreSQL with Python Pyramid, but I do not want to use the ORM? Or can I just use the psycopg2 directly? And how to do that?
Upvotes: 0
Views: 320
Reputation: 31
you can use psycopg2-wrapper for executing query or commands on psycopg2.
For installation;
pip install psycopg2-wrapper
For usage;
from psycopg2_wrapper.database import Database
database = Database(host='', database='', user='', password='')
database.execute_query('select * from user where id=%s', (1,))
Upvotes: 3
Reputation: 2433
Even if you do not want to use ORM, you can still use SQLAlchemy's query language.
If you do not want to use SQLAlchemy, you can certainly use psycopg2 directly. Look into Pyramid cookbook - MongoDB and Pyramid or CouchDB and Pyramid for inspiration.
Upvotes: 0