]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- oursql dialect accepts the same "ssl" arguments in
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 10 Feb 2011 23:04:54 +0000 (18:04 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 10 Feb 2011 23:04:54 +0000 (18:04 -0500)
create_engine() as that of MySQLdb.  [ticket:2047]

CHANGES
lib/sqlalchemy/dialects/mysql/oursql.py
test/dialect/test_mysql.py

diff --git a/CHANGES b/CHANGES
index e3682d688540407d371749b9966ff4a6d71278f8..0e87855fb5e2135dba70c3282dece4bdf0454233 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -299,6 +299,10 @@ CHANGES
     exceptions, "could not receive data from server"
     [ticket:2044]
 
+- mysql
+  - oursql dialect accepts the same "ssl" arguments in 
+    create_engine() as that of MySQLdb.  [ticket:2047]
+
 0.6.6
 =====
 - orm
index 8caa1eaec85319842a323acd1cf8e022caf83f15..ff5ecfc9318684becb471a8c89e2d820fa23213a 100644 (file)
@@ -222,6 +222,16 @@ class MySQLDialect_oursql(MySQLDialect):
         # supports_sane_rowcount.
         opts.setdefault('found_rows', True)
 
+        ssl = {}
+        for key in ['ssl_ca', 'ssl_key', 'ssl_cert', 
+                        'ssl_capath', 'ssl_cipher']:
+            if key in opts:
+                ssl[key[4:]] = opts[key]
+                util.coerce_kw_type(ssl, key[4:], str)
+                del opts[key]
+        if ssl:
+            opts['ssl'] = ssl
+
         return [[], opts]
 
     def _get_server_version_info(self, connection):
index 9b92ddb092033c630e43f315982d60538483e7ac..a805d9838fdbd7b7acb8ac0039bfd64f7bbd47ce 100644 (file)
@@ -9,11 +9,39 @@ import sets
 from sqlalchemy import *
 from sqlalchemy import sql, exc, schema, types as sqltypes, event
 from sqlalchemy.dialects.mysql import base as mysql
+from sqlalchemy.engine.url import make_url
+
 from test.lib.testing import eq_
 from test.lib import *
 from test.lib.engines import utf8_engine
 import datetime
 
+
+class DialectTest(TestBase):
+    __only_on__ = 'mysql'
+
+    @testing.only_on(['mysql+mysqldb', 'mysql+oursql'], 
+                    'requires particular SSL arguments')
+    def test_ssl_arguments(self):
+        dialect = testing.db.dialect
+        kwarg = dialect.create_connect_args(
+            make_url("mysql://scott:tiger@localhost:3306/test"
+                "?ssl_ca=/ca.pem&ssl_cert=/cert.pem&ssl_key=/key.pem")
+        )[1]
+        # args that differ among mysqldb and oursql
+        for k in ('use_unicode', 'found_rows', 'client_flag'):
+            kwarg.pop(k, None)
+        eq_(
+            kwarg, 
+            {
+                'passwd': 'tiger', 'db': 'test', 
+                'ssl': {'ca': '/ca.pem', 'cert': '/cert.pem', 
+                        'key': '/key.pem'}, 
+                'host': 'localhost', 'user': 'scott', 
+                'port': 3306
+            }
+        )
+
 class TypesTest(TestBase, AssertsExecutionResults, AssertsCompiledSQL):
     "Test MySQL column types"