1. Jan Brohl
  2. pydal


pydal / pydal / dbapi.py

Diff from to

File pydal/dbapi.py

 Usage Example:
-import dal
+import pydal.dbapi as dal
+import pydal.dbexceptions as ex
 dbmod = dal.wrapdriver('psycopg')
 # (Optional) Set the datetime type you want to use.
 # Defaults to Python's datetime module.  Can be 'mx', 'py', or 'native'.
     result = cs.fetchall()
 # all DBAPI2 exceptions from the driver are mapped to the corresponding dal 
 # exceptions so it is possible to catch them in a generic way.
-except dal.Error:
+except ex.Error:
 are in fact SQL server and driver specific and unfortunately hasn't been 
 addressed in Python DBAPI spec. Below is the example for MySQLdb.
-import dal
+import pydal.dbapi as dal
 dbmod = dal.wrapdriver('MySQLdb')
 # Set local timezone. This gives side effect that all datetime.datetime 
 # sent as a query parameters has been converted internally to this 
 # timezone before sending to driver.
-dal.dbapi.dbtime.server_tzinfo = pytz.timezone('UTC') 
+dal.dbtime.server_tzinfo = pytz.timezone('UTC') 
 dbmod.dtmod = 'py' # Python datetime module.
 dbmod.paramstyle = 'qmark'
 __revision__ = 0.1
-import dbtime
-import dbexceptions
-import paramstyles
+import pydal.dbtime as dbtime
+import pydal.dbexceptions as dbexceptions
+import pydal.paramstyles as paramstyles
 class MWrapper(object):
     """Wraps DBAPI2 driver."""
         return self._native_cs.description
     description = property(__getDescription)
     def __getRowCount(self):
         return self._native_cs.rowcount
         return self._native_cs.arraysize
     def __setArraySize(self, new_array_size):
-        self._native_cs.arraysize = new_array_size 
+        self._native_cs.arraysize = new_array_size
     arraysize = property(__getArraySize, __setArraySize)
         elif results != []:
             new_results = results
-            new_results = [] 
+            new_results = []
         return new_results
     def close(self):
     if driver_alias == None:
         driver_alias = driver_name
-        driver = __import__(driver_name, fromlist = [ '' ])
+        driver = __import__(driver_name, fromlist=[ '' ])
     except ImportError:
     # create the MWrapper instance