jaboja
jaboja

Reputation: 2237

How to use PostgreSQL in Python Pyramid without ORM

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

Answers (2)

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

Petr Blahos
Petr Blahos

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

Related Questions