A simple (too simple?) patch to support SSL connections with MySQL.

Use the following syntax to use it:

 mysql://user:[EMAIL PROTECTED]/db?ssl_ca=<path-to-ca-file>

Tested with SA from svn, mysql-5.0.27, python-2.4.4 and MySQL-
python-1.2.1.

 - Terje


  Index: lib/sqlalchemy/databases/mysql.py
===================================================================
--- lib/sqlalchemy/databases/mysql.py   (revisjon 2530)
+++ lib/sqlalchemy/databases/mysql.py   (arbeidskopi)
@@ -293,8 +293,21 @@
         # note: these two could break SA Unicode type
         util.coerce_kw_type(opts, 'use_unicode', bool)
         util.coerce_kw_type(opts, 'charset', str)
-        # TODO: what about options like "ssl", "cursorclass" and
"conv" ?
+        # ssl
+        ssl_opts = ['key', 'cert', 'ca', 'capath', 'cipher']
+        for opt in ssl_opts:
+            util.coerce_kw_type(opts, 'ssl_' + opt, str)
+        # ssl_ca option is required to use ssl
+        if 'ssl_ca' in opts.keys():
+            # ssl arg must be a dict
+            ssl = {}
+            for opt in ssl_opts:
+                if 'ssl_' + opt in opts.keys():
+                    ssl[opt] = opts['ssl_' + opt]
+                    del opts['ssl_' + opt]
+            opts['ssl'] = ssl

+        # TODO: what about options like "cursorclass" and "conv" ?
         client_flag = opts.get('client_flag', 0)
         if self.dbapi is not None:
             try:


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to