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

Source Code for Module logilab.common.db

 1  # copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. 
 2  # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr 
 3  # 
 4  # This file is part of logilab-common. 
 5  # 
 6  # logilab-common is free software: you can redistribute it and/or modify it under 
 7  # the terms of the GNU Lesser General Public License as published by the Free 
 8  # Software Foundation, either version 2.1 of the License, or (at your option) any 
 9  # later version. 
10  # 
11  # logilab-common is distributed in the hope that it will be useful, but WITHOUT 
12  # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
13  # FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more 
14  # details. 
15  # 
16  # You should have received a copy of the GNU Lesser General Public License along 
17  # with logilab-common.  If not, see <http://www.gnu.org/licenses/>. 
18  """Wrappers to get actually replaceable DBAPI2 compliant modules and 
19  database connection whatever the database and client lib used. 
20   
21  Currently support: 
22   
23  - postgresql (pgdb, psycopg, psycopg2, pyPgSQL) 
24  - mysql (MySQLdb) 
25  - sqlite (pysqlite2, sqlite, sqlite3) 
26   
27  just use the `get_connection` function from this module to get a 
28  wrapped connection.  If multiple drivers for a database are available, 
29  you can control which one you want to use using the 
30  `set_prefered_driver` function. 
31   
32  Additional helpers are also provided for advanced functionalities such 
33  as listing existing users or databases, creating database... Get the 
34  helper for your database using the `get_adv_func_helper` function. 
35  """ 
36  __docformat__ = "restructuredtext en" 
37   
38  from warnings import warn 
39  warn('this module is deprecated, use logilab.database instead', 
40       DeprecationWarning, stacklevel=1) 
41   
42  from logilab.database import (get_connection, set_prefered_driver, 
43                          get_dbapi_compliant_module as _gdcm, 
44                          get_db_helper as _gdh) 
45   
46 -def get_dbapi_compliant_module(driver, *args, **kwargs):
47 module = _gdcm(driver, *args, **kwargs) 48 module.adv_func_helper = _gdh(driver) 49 return module
50