]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
[ticket:256] propigating url.query arguments to connect() function for all db's
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 25 Jul 2006 16:40:38 +0000 (16:40 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 25 Jul 2006 16:40:38 +0000 (16:40 +0000)
CHANGES
lib/sqlalchemy/databases/firebird.py
lib/sqlalchemy/databases/mssql.py
lib/sqlalchemy/databases/mysql.py
lib/sqlalchemy/databases/oracle.py
lib/sqlalchemy/databases/postgres.py
lib/sqlalchemy/databases/sqlite.py

diff --git a/CHANGES b/CHANGES
index a347df98da202d15fd1e6c23d9e45104572c08be..6a90e742423d2d52b4518c3743b93283270ddfda 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -5,6 +5,7 @@ by not raising an error when redundant mappers were set up, fixed
 primary key columns are null (i.e. when mapping to outer joins etc)
 - fixed reflection of foreign keys to autoload the referenced table
 if it was not loaded already
+- [ticket:256] - pass URL query string arguments to connect() function
 
 0.2.6
 - big overhaul to schema to allow truly composite primary and foreign
index 085d8cf444c91e150cfb34d975d4b33074a39718..bef1855976e873976579ac35600b61070ef9d882 100644 (file)
@@ -123,6 +123,10 @@ class FireBirdDialect(ansisql.ANSIDialect):
         if opts.get('port'):
             opts['host'] = "%s/%s" % (opts['host'], opts['port'])
             del opts['port']
+        opts.update(url.query)
+        # pop arguments that we took at the module level
+        opts.pop('type_conv', None)
+        opts.pop('concurrency_level', None)
         self.opts = opts
         
         return ([], self.opts)
index 9d51d535dad38ce507251321457c24b62dbf3702..6613009fc1ab3618b803c6ef6e36e552e177ed5a 100644 (file)
@@ -241,6 +241,7 @@ class MSSQLDialect(ansisql.ANSIDialect):
 
     def create_connect_args(self, url):
         self.opts = url.translate_connect_args(['host', 'database', 'user', 'password', 'port'])
+        self.opts.update(url.query)
         return ([], self.opts)
 
     def connect_args(self):
index 3f3e8d14847603752a5a529112a2db97e1b81940..c9ebd7ba630e346a3c247c3b3148a633396e1c13 100644 (file)
@@ -265,6 +265,18 @@ class MySQLDialect(ansisql.ANSIDialect):
 
     def create_connect_args(self, url):
         opts = url.translate_connect_args(['host', 'db', 'user', 'passwd', 'port'])
+        opts.update(url.query)
+        def coercetype(param, type):
+            if param in opts and type(param) is not type:
+                if type is bool:
+                    opts[param] = bool(int(opts[param]))
+                else:
+                    opts[param] = type(opts[param])
+        coercetype('compress', bool)
+        coercetype('connect_timeout', int)
+        coercetype('use_unicode', bool)   # this could break SA Unicode type
+        coercetype('charset', str)        # this could break SA Unicode type
+        # TODO: what about options like "ssl", "cursorclass" and "conv" ?
         return [[], opts]
 
     def create_execution_context(self):
index c279da619f0d768e865151b6bed8e1c1873839d2..897ed640efe1ae204a476147fdceffbca86c2cd0 100644 (file)
@@ -141,6 +141,7 @@ class OracleDialect(ansisql.ANSIDialect):
             dsn = dsn,
             threaded = self.threaded
             )
+        opts.update(url.query)
         return ([], opts)
         
     def type_descriptor(self, typeobj):
index decccba58d1bd4230c25ac3efe495288e8bc4cd4..8368c89315ffcce58bc5680f37baae57f23b2be1 100644 (file)
@@ -225,6 +225,7 @@ class PGDialect(ansisql.ANSIDialect):
                 opts['port'] = int(opts['port'])
             else:
                 opts['port'] = str(opts['port'])
+        opts.update(url.query)
         return ([], opts)
 
     def create_execution_context(self):
index c703cd81eb97ca92f01f774c83493c6221c2be19..c681f391ad100729981d41ab55e0fdbb1facf459 100644 (file)
@@ -141,7 +141,7 @@ class SQLiteDialect(ansisql.ANSIDialect):
         return SQLiteSchemaGenerator(*args, **kwargs)
     def create_connect_args(self, url):
         filename = url.database or ':memory:'
-        return ([filename], {})
+        return ([filename], url.query)
     def type_descriptor(self, typeobj):
         return sqltypes.adapt_type(typeobj, colspecs)
     def create_execution_context(self):