diff --git a/gluon/dal.py b/gluon/dal.py index 7b891937..ab120ace 100644 --- a/gluon/dal.py +++ b/gluon/dal.py @@ -117,6 +117,7 @@ Supported DAL URI strings: 'firebird_embedded://username:password@c://path' 'informix://user:password@server:3050/database' 'informixu://user:password@server:3050/database' # unicode informix +'ingres://database' # or use an ODBC connection string, e.g. 'ingres://dsn=dsn_name' 'google:datastore' # for google app engine datastore 'google:sql' # for google app engine with sql (mysql compatible) 'teradata://DSN=dsn;UID=user;PWD=pass; DATABASE=database' # experimental @@ -350,8 +351,9 @@ if not 'google' in DRIVERS: DRIVERS.append('MSSQL(pyodbc)') DRIVERS.append('DB2(pyodbc)') DRIVERS.append('Teradata(pyodbc)') + DRIVERS.append('Ingres(pyodbc)') except ImportError: - LOGGER.debug('no MSSQL/DB2/Teradata driver pyodbc') + LOGGER.debug('no MSSQL/DB2/Teradata/Ingres driver pyodbc') try: import Sybase @@ -413,13 +415,6 @@ if not 'google' in DRIVERS: LOGGER.debug('no SQLite/PostgreSQL driver zxJDBC') is_jdbc = False - try: - import ingresdbi - DRIVERS.append('Ingres(ingresdbi)') - except ImportError: - LOGGER.debug('no Ingres driver ingresdbi') - # NOTE could try JDBC....... - try: import couchdb DRIVERS.append('CouchDB(couchdb)') @@ -3862,7 +3857,7 @@ INGRES_SEQNAME='ii***lineitemsequence' # NOTE invalid database object name # to be a delimited identifier) class IngresAdapter(BaseAdapter): - drivers = ('ingresdbi',) + drivers = ('pyodbc',) types = { 'boolean': 'CHAR(1)', @@ -3913,6 +3908,7 @@ class IngresAdapter(BaseAdapter): adapter_args={}, do_connect=True, after_connection=None): self.db = db self.dbengine = "ingres" + self._driver = pyodbc self.uri = uri if do_connect: self.find_driver(adapter_args,uri) self.pool_size = pool_size @@ -3925,17 +3921,22 @@ class IngresAdapter(BaseAdapter): connstr = connstr.lstrip() while connstr.startswith('/'): connstr = connstr[1:] - database_name=connstr # Assume only (local) dbname is passed in - vnode = '(local)' - servertype = 'ingres' - trace = (0, None) # No tracing - driver_args.update(database=database_name, - vnode=vnode, - servertype=servertype, - trace=trace) - def connector(driver_args=driver_args): - return self.driver.connect(**driver_args) + if '=' in connstr: + # Assume we have a regular ODBC connection string and just use it + ruri = connstr + else: + # Assume only (local) dbname is passed in with OS auth + database_name = connstr + default_driver_name = 'Ingres' + vnode = '(local)' + servertype = 'ingres' + ruri = 'Driver={%s};Server=%s;Database=%s' % (default_driver_name, vnode, database_name) + def connector(cnxn=ruri,driver_args=driver_args): + return self.driver.connect(cnxn,**driver_args) + self.connector = connector + + # TODO if version is >= 10, set types['id'] to Identity column, see http://community.actian.com/wiki/Using_Ingres_Identity_Columns if do_connect: self.reconnect() def create_sequence_and_triggers(self, query, table, **args): @@ -3961,12 +3962,12 @@ class IngresAdapter(BaseAdapter): return int(self.cursor.fetchone()[0]) # don't really need int type cast here... def integrity_error_class(self): - return ingresdbi.IntegrityError + return self._driver.IntegrityError class IngresUnicodeAdapter(IngresAdapter): - drivers = ('ingresdbi',) + drivers = ('pyodbc',) types = { 'boolean': 'CHAR(1)',