Package picalo :: Module Database
[show private | hide private]
[frames | no frames]

Module picalo.Database

This module provides easy access to DB-API 2.0 tables. It is a decorator for connections and cursors. Cursor results can be accessed efficiently via field name or index.

Right now ODBC data sources are the primary mechanism to access databases. Set up ODBC in your operating system and call the OdbcConnection method to create a connection. In addition, direct connections to MySQL and PostgreSQL are supported (without the need for an ODBC DSN setup).

The primary use of this module is table(), which returns a standard Picalo table. Other methods are provided for advanced users who want more control over the databse connection.

Most users only need to learn how to 1) create Connection objects, and 2) run conn.table() to query database tables.

The module also provides classes to ease the creation of insert, update, and select queries.
Classes
InsertQueryBuilder Helps in building a simple insert SQL call.
Query Represents a query on a database.
SelectQueryBuilder Helps in building a simple select SQL call.
UpdateQueryBuilder Helps in building a simple update SQL call.

Exceptions
QueryBuilderException Simple exception to report query builder problems, with an embedded error.

Function Summary
  load(filename)
Loads the connection from the given filename.
  load_query(filename)
Loads the query from the given filename.
_Connection MySQLConnection(database, username, password, host, port)
Opens a database connection to a MySQL database using the MySQLdb driver.
_Connection OdbcConnection(dsn_name, username, password)
Opens a database connection to an ODBC database using the PyODBC driver.
_Connection PostgreSQLConnection(database, username, password, host, port)
Opens a database connection to a PostgreSQL database using the psycopg2 driver.
  save(conn, filename)
Saves the given connection to the filename.
  save_query(query, filename)
Saves the given connection to the filename.

Variable Summary
tuple __functions__ = ('OdbcConnection', 'PostgreSQLConnection...
int PICKLE_PROTOCOL = 2                                                                     

Function Details

load(filename)

Loads the connection from the given filename.
Parameters:
filename - The filename to load from. This can also be an open stream.
           (type=str)

load_query(filename)

Loads the query from the given filename.
Parameters:
filename - The filename to load from. This can also be an open stream.
           (type=str)

MySQLConnection(database, username=None, password=None, host=None, port=None)

Opens a database connection to a MySQL database using the MySQLdb driver.
Parameters:
database - The database name to connect to.
           (type=str)
username - Your username for the connection.
           (type=str)
password - Your password for the connection.
           (type=str)
host - The server hostname or IP address.
           (type=str)
port - The server port to connect on.
           (type=int)
Returns:
A database connection.
           (type=_Connection)

OdbcConnection(dsn_name, username=None, password=None)

Opens a database connection to an ODBC database using the PyODBC driver.
Parameters:
dsn_name - The DSN string to your database (as defined in the control panel)
           (type=str)
username - Your username for the connection
           (type=str)
password - Your password for the connection
           (type=str)
Returns:
A database connection.
           (type=_Connection)

PostgreSQLConnection(database, username=None, password=None, host=None, port=None)

Opens a database connection to a PostgreSQL database using the psycopg2 driver.
Parameters:
database - The database name to connect to.
           (type=str)
username - Your username for the connection.
           (type=str)
password - Your password for the connection.
           (type=str)
host - The server hostname or IP address.
           (type=str)
port - The server port to connect on.
           (type=int)
Returns:
A database connection.
           (type=_Connection)

save(conn, filename)

Saves the given connection to the filename.
Parameters:
conn - The database connection to save.
           (type=Picalo Database Connection)
filename - The filename to save to. This can also be an open stream.
           (type=str)

save_query(query, filename)

Saves the given connection to the filename.
Parameters:
query - The query object to save.
           (type=Picalo Query object)
filename - The filename to save to. This can also be an open stream.
           (type=str)

Variable Details

__functions__

Type:
tuple
Value:
('OdbcConnection', 'PostgreSQLConnection', 'MySQLConnection')          

PICKLE_PROTOCOL

Type:
int
Value:
2                                                                     

Generated by Epydoc 2.1 on Mon Aug 20 05:38:17 2007 http://epydoc.sf.net