Hey, SQLAlchemy folks... sorry to bug you during your sprint (wish I could be there - next year, I hope), but I've got a patch for you that I hope will be really quick and easy to review and apply. I've attached it here, and also to the trac ticket:
http://www.sqlalchemy.org/trac/ticket/1361 We (the sqlpython development group - yes, we're a "we" now, w00t!) need it to finish switching our connection management over to sqlalchemy - we need to accept Oracle connection strings like "sys/syspas...@tns_alias AS SYSDBA", and without the patch I don't think create_engine can handle it. (AS SYSDBA requires ?mode=2 on the connection URL, but parameterized urls are only accepted by create_engine when the host and database names are explicit, not when a TNS alias is used. I think that was oversight, not design.) Thanks very much, and happy sprinting! -- - Catherine http://catherinedevlin.blogspot.com/ *** PyCon * March 27-29, 2009 * Chicago * us.pycon.org *** --~--~---------~--~----~------------~-------~--~----~ 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 sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---
diff -r f6ec438a57f3 lib/sqlalchemy/engine/url.py --- a/lib/sqlalchemy/engine/url.py Tue Mar 31 14:57:19 2009 +0000 +++ b/lib/sqlalchemy/engine/url.py Tue Mar 31 16:20:35 2009 -0400 @@ -138,6 +138,15 @@ def make_url(name_or_url): else: return name_or_url + +def _extract_query(target): + tokens = target.split('?', 2) + remnant = tokens[0] + query = (len(tokens) > 1 and dict(cgi.parse_qsl(tokens[1]))) or None + if query is not None: + query = dict((k.encode('ascii'), query[k]) for k in query) + return (remnant, query) + def _parse_rfc1738_args(name): pattern = re.compile(r''' (?P<name>\w+):// @@ -157,11 +166,9 @@ def _parse_rfc1738_args(name): if m is not None: components = m.groupdict() if components['database'] is not None: - tokens = components['database'].split('?', 2) - components['database'] = tokens[0] - query = (len(tokens) > 1 and dict(cgi.parse_qsl(tokens[1]))) or None - if query is not None: - query = dict((k.encode('ascii'), query[k]) for k in query) + (components['database'], query) = _extract_query(components['database']) + elif components['host'] is not None: + (components['host'], query) = _extract_query(components['host']) else: query = None components['query'] = query