Commits

Mike Bayer committed 1b7c9c2

firebird patch with support for type_conv

Comments (0)

Files changed (1)

lib/sqlalchemy/databases/firebird.py

 # the MIT License: http://www.opensource.org/licenses/mit-license.php
 
 
-import sys, StringIO, string
+import sys, StringIO, string, types
 
 import sqlalchemy.engine.default as default
 # import sqlalchemy.sql as sql
         
 dbmodule = kinterbasdb
         
-kinterbasdb.init(200)    # fix this, init args should be passable via db_uri
+_initialized_kb = False        
+
 
 class FBNumeric(sqltypes.Numeric):
     def get_col_spec(self):
         
 class FireBirdDialect(ansisql.ANSIDialect):
     def __init__(self, module = None, **params):
+        global _initialized_kb
         self.module = module or dbmodule
         self.opts = {}
+        
+        if not _initialized_kb:
+            _initialized_kb = True
+            type_conv = params.get('type_conv', 200) or 200
+            if isinstance(type_conv, types.StringTypes):
+                type_conv = int(type_conv)
+                
+            concurrency_level = params.get('concurrency_level', 1) or 1
+            if isinstance(concurrency_level, types.StringTypes):
+                concurrency_level = int(concurrency_level)
+            
+            kinterbasdb.init(type_conv=type_conv, concurrency_level=concurrency_level)
         ansisql.ANSIDialect.__init__(self, **params)
 
     def create_connect_args(self, url):
             del opts['port']
         self.opts = opts
         
-        print "opts %r" % self.opts
         return ([], self.opts)
 
     def connect_args(self):
         #import pdb;pdb.set_trace()
         # get all of the fields for this table
         c = connection.execute(tblqry, [table.name.upper()])
-        found_table = False
         while True:
             row = c.fetchone()
             if not row: break
-            found_table = True
             args = [row['FNAME']]
             kw = {}
             # get the data types and lengths
             # is it a primary key?
             table.append_item(schema.Column(*args, **kw))
             # does the field have indexes
-        
-        if not found_table:
-            raise exceptions.NoSuchTableError(table.name)
 
     def last_inserted_ids(self):
         return self.context.last_inserted_ids