summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/databases/mxODBC.py
diff options
context:
space:
mode:
authorJason Kirtland <jek@discorporate.us>2007-10-13 20:26:24 +0000
committerJason Kirtland <jek@discorporate.us>2007-10-13 20:26:24 +0000
commit9f525a01455b1127e05c2baa69bd0dd34c93f3b0 (patch)
treecd6eb08c1bb12f7d8c8665c49c81a247ce791600 /lib/sqlalchemy/databases/mxODBC.py
parent05b07dfb177b5e5d537e9cf58e52c9101224564d (diff)
downloadsqlalchemy-9f525a01455b1127e05c2baa69bd0dd34c93f3b0.tar.gz
Fixed reference bug in Connect, switched docstring format
Diffstat (limited to 'lib/sqlalchemy/databases/mxODBC.py')
-rw-r--r--lib/sqlalchemy/databases/mxODBC.py34
1 files changed, 13 insertions, 21 deletions
diff --git a/lib/sqlalchemy/databases/mxODBC.py b/lib/sqlalchemy/databases/mxODBC.py
index 61649b9b3..a3acac587 100644
--- a/lib/sqlalchemy/databases/mxODBC.py
+++ b/lib/sqlalchemy/databases/mxODBC.py
@@ -5,36 +5,30 @@
# This module is part of SQLAlchemy and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
-'''
+"""
A wrapper for a mx.ODBC.Windows DB-API connection.
-Makes sure the mx module is configured to return datetime objects instead of
-mx.DateTime.DateTime objects.
-'''
+Makes sure the mx module is configured to return datetime objects instead
+of mx.DateTime.DateTime objects.
+"""
from mx.ODBC.Windows import *
-
-'''
-Override the 'cursor' method.
-'''
-
class Cursor:
-
def __init__(self, cursor):
self.cursor = cursor
-
+
def __getattr__(self, attr):
res = getattr(self.cursor, attr)
return res
-
+
def execute(self, *args, **kwargs):
res = self.cursor.execute(*args, **kwargs)
return res
-class Connection:
+class Connection:
def myErrorHandler(self, connection, cursor, errorclass, errorvalue):
err0, err1, err2, err3 = errorvalue
#print ", ".join(["Err%d: %s"%(x, errorvalue[x]) for x in range(4)])
@@ -42,27 +36,25 @@ class Connection:
# Ignore "Null value eliminated in aggregate function", this is not an error
return
raise errorclass, errorvalue
-
+
def __init__(self, conn):
self.conn = conn
# install a mx ODBC error handler
self.conn.errorhandler = self.myErrorHandler
-
+
def __getattr__(self, attr):
res = getattr(self.conn, attr)
return res
-
+
def cursor(self, *args, **kwargs):
res = Cursor(self.conn.cursor(*args, **kwargs))
return res
-
+
+
# override 'connect' call
def connect(*args, **kwargs):
import mx.ODBC.Windows
conn = mx.ODBC.Windows.Connect(*args, **kwargs)
conn.datetimeformat = mx.ODBC.Windows.PYDATETIME_DATETIMEFORMAT
return Connection(conn)
-
-# override 'Connect' call
-def Connect(*args, **kwargs):
- return self.connect(*args, **kwargs)
+Connect = connect