Python driver for postgresql

What is the best driver in python to connect to postgresql?

There are several features of http://wiki.postgresql.org/wiki/Python , but I don’t know which one is the best choice.

Any idea?

+5
source share
2 answers

I would recommend sqlalchemy - it offers more flexibility and has a complicated intuition.

Moreover, it is not associated only with postgresql.

Shameless c & p from tutorial :

from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker

# an Engine, which the Session will use for connection
# resources
some_engine = create_engine('postgresql://scott:tiger@localhost/')

# create a configured "Session" class
Session = sessionmaker(bind=some_engine)

# create a Session
session = Session()

# work with sess
myobject = MyObject('foo', 'bar')
session.add(myobject)
session.commit()

Clarifications due to comments (update):

sqlalchemy , - . , postgresql- libpq, psycopg2.

OP , , " " " postgresql", sqlalchemy, , , .

" " , , - , .

, .

+9

psycopg2 is the one everyone uses with CPython. However, for PyPy you want to look at pure Python.

+12
source

All Articles