The dbconn module defines DbConnection.
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 and yamltodb, it will typically connect to the database when the DbObjectDict fetch() method is first invoked. It is normally disconnected just before the Database from_catalog() returns.
A database connection, possibly disconnected
Connect to the database
Close the database connection
Commit currently open transaction
Roll back currently open transaction
Create a cursor, execute a query and return the cursor
Parameters: |
|
---|---|
Returns: | cursor |
Execute a single row SELECT query and return row
Parameters: |
|
---|---|
Returns: | a psycopg2 DictRow |
The cursor is closed.
Execute a SELECT query and return rows
Parameters: |
|
---|---|
Returns: | a list of psycopg2 DictRow’s |
The cursor is closed.