Permalink
Browse files

implementation of pyodbc support

  • Loading branch information...
1 parent 09fa07e commit a74969808dc390900b6d928627916abcce2d1d58 ggb committed with Mar 17, 2012
Showing with 23 additions and 0 deletions.
  1. +20 −0 twistar/dbconfig/pyodbc.py
  2. +3 −0 twistar/registry.py
View
20 twistar/dbconfig/pyodbc.py
@@ -0,0 +1,20 @@
+from twistar.registry import Registry
+from twistar.dbconfig.base import InteractionBase
+
+class PyODBCDBConfig(InteractionBase):
+
+ def whereToString(self, where):
+ assert(type(where) is list)
+ query = where[0] #? will be correct
+ args = where[1:]
+ return (query, args)
+
+
+ def updateArgsToString(self, args):
+ colnames = self.escapeColNames(args.keys())
+ setstring = ",".join([key + " = ?" for key in colnames])
+ return (setstring, args.values())
+
+
+ def insertArgsToString(self, vals):
+ return "(" + ",".join(["?" for _ in vals.items()]) + ")"
View
3 twistar/registry.py
@@ -78,6 +78,9 @@ def getConfig(klass):
elif dbapi.__name__ == "psycopg2":
from twistar.dbconfig.postgres import PostgreSQLDBConfig
Registry.IMPL = PostgreSQLDBConfig()
+ elif dbapi.__name__ == "pyodbc":
+ from twistar.dbconfig.pyodbc import PyODBCDBConfig
+ Registry.IMPL = PyODBCDBConfig()
else:
raise NotImplementedError, "twisteddb does not support the %s driver" % dbapi.__name__

0 comments on commit a749698

Please sign in to comment.