16 |
# write to the Free Software Foundation, Inc., 59 Temple Place |
# write to the Free Software Foundation, Inc., 59 Temple Place |
17 |
# - Suite 330, Boston, MA 02111-1307, USA. |
# - Suite 330, Boston, MA 02111-1307, USA. |
18 |
# |
# |
19 |
# Copyright 2000, 2001 Free Software Foundation |
# Copyright 2000-2003 Free Software Foundation |
20 |
# |
# |
21 |
# FILE: |
# FILE: |
22 |
# odbc/DBdriver.py |
# odbc/DBdriver.py |
49 |
# to generate an ImportError early on if not installed. |
# to generate an ImportError early on if not installed. |
50 |
from mx import ODBC |
from mx import ODBC |
51 |
except ImportError, message: |
except ImportError, message: |
52 |
raise GConnections.AdapterNotInstalled, \ |
tmsg = _("Driver not installed: ODBC\nGrab mxODBC from ") + \ |
|
_("Driver not installed: ODBC\nGrab mxODBC from ") + \ |
|
53 |
"http://www.lemburg.com/files/python/mxODBC.html\n\n[%s]" % message |
"http://www.lemburg.com/files/python/mxODBC.html\n\n[%s]" % message |
54 |
|
raise GConnections.AdapterNotInstalled, tmsg |
55 |
|
|
56 |
|
|
57 |
class ODBC_RecordSet(DBSIG_RecordSet): |
class ODBC_RecordSet(DBSIG_RecordSet): |
79 |
self._backend = dyn_import("mx.ODBC.%s" % backend) |
self._backend = dyn_import("mx.ODBC.%s" % backend) |
80 |
self._DatabaseError = self._backend.DatabaseError |
self._DatabaseError = self._backend.DatabaseError |
81 |
except ValueError: |
except ValueError: |
82 |
raise GDataObjects.ConnectionError, \ |
tmsg = _('Invalid service string for ODBC driver.\n') +\ |
83 |
_('Invalid service string for ODBC driver.\n') +\ |
_('Format: service="Backend|DSNString"') |
84 |
_('Format: service="Backend|DSNString"') |
raise GDataObjects.ConnectionError, tmsg |
85 |
except ImportError, mesg: |
except ImportError, mesg: |
86 |
raise GConnections.AdapterNotInstalled, \ |
tmsg = _('Unable to load the ODBC drivers for %s') % backend |
87 |
_('Unable to load the ODBC drivers for %s') % backend |
raise GConnections.AdapterNotInstalled, tmsg |
88 |
|
|
89 |
try: |
try: |
90 |
self._dataConnection = SIG2api.connect( dsn, \ |
self._dataConnection = SIG2api.connect( dsn, \ |