Contents
Database Connections
module: pyrseas.lib.dbconn
The dbconn module defines DbConnection.
Database Connection
A DbConnection is a helper class representing a connection to a PostgreSQL database via the Psycopg adapter. It provides an easier interface than direct access to Psycopg. For example:
>>> from pyrseas.lib.dbconn import DbConnection >>> db = DbConnection('dbname') >>> db.fetchone("SHOW server_version")[0] >>> db.commit()
A DbConnection is not necessarily connected. In the case of Pyrseas dbtoyaml </dbtoyaml> and yamltodb </yamltodb>, it will typically connect to the database when the ~pyrseas.dbobject.DbObjectDict ~pyrseas.dbobject.DbObjectDict.fetch method is first invoked. It is normally disconnected just before the ~pyrseas.database.Database ~pyrseas.database.Database.from_catalog returns.
autoclass: DbConnection
automethod: DbConnection.connect
automethod: DbConnection.close
automethod: DbConnection.commit
automethod: DbConnection.rollback
automethod: DbConnection.execute
automethod: DbConnection.fetchone
automethod: DbConnection.fetchall