Package logilab :: Package common :: Module db
[frames] | no frames]

Module db

source code

Wrappers to get actually replaceable DBAPI2 compliant modules and
database connection whatever the database and client lib used.

Currently support:

- postgresql (pgdb, psycopg, psycopg2, pyPgSQL)
- mysql (MySQLdb)
- sqlite (pysqlite2, sqlite, sqlite3)

just use the `get_connection` function from this module to get a
wrapped connection.  If multiple drivers for a database are available,
you can control which one you want to use using the
`set_prefered_driver` function.

Additional helpers are also provided for advanced functionalities such
as listing existing users or databases, creating database... Get the
helper for your database using the `get_adv_func_helper` function.

:copyright: 2002-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
:license: General Public License version 2 - http://www.gnu.org/licenses

Classes
  NoAdapterFound
Raised when no Adapter to DBAPI was found
  PyConnection
A simple connection wrapper in python, generating wrapper for cursors as...
  PyCursor
A simple cursor wrapper in python (useful for profiling)
  UnknownDriver
raised when a unknown driver is given to get connection
Functions
 
get_connection(driver='postgres', host='', database='', user='', password='', port='', quiet=False, drivers={'mysql': ['MySQLdb'], 'postgres': ['psycopg2', 'psycopg', 'pg..., pywrap=False)
return a db connection according to given arguments
source code
 
get_dbapi_compliant_module(driver, prefered_drivers=None, quiet=False, pywrap=False)
returns a fully dbapi compliant module
source code
 
set_prefered_driver(database, module, _drivers={'mysql': ['MySQLdb'], 'postgres': ['psycopg2', 'psycopg', 'pg...)
sets the preferred driver module for database...
source code
Function Details

set_prefered_driver(database, module, _drivers={'mysql': ['MySQLdb'], 'postgres': ['psycopg2', 'psycopg', 'pg...)

source code 
sets the preferred driver module for database
database is the name of the db engine (postgresql, mysql...)
module is the name of the module providing the connect function
syntax is (params_func, post_process_func_or_None)
_drivers is a optional dictionary of drivers