From: Mike Bayer Date: Sun, 23 Sep 2012 22:30:16 +0000 (-0400) Subject: - [feature] An experimental dialect for the fdb X-Git-Tag: rel_0_8_0b1~132 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=20fe4a012ebf6140a53191032e00d3bda7540553;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - [feature] An experimental dialect for the fdb driver is added, but is untested as I cannot get the fdb package to build. [ticket:2504] --- diff --git a/CHANGES b/CHANGES index a1571c90e2..a919d394b1 100644 --- a/CHANGES +++ b/CHANGES @@ -698,6 +698,10 @@ underneath "0.7.xx". using the DateTime type with Firebird; other dialects support this. + - [feature] An experimental dialect for the fdb + driver is added, but is untested as I cannot + get the fdb package to build. [ticket:2504] + - mysql - [bug] Dialect no longer emits expensive server collations query, as well as server casing, diff --git a/doc/build/dialects/firebird.rst b/doc/build/dialects/firebird.rst index 000a8355e6..2ec0103eff 100644 --- a/doc/build/dialects/firebird.rst +++ b/doc/build/dialects/firebird.rst @@ -11,3 +11,8 @@ kinterbasdb ----------- .. automodule:: sqlalchemy.dialects.firebird.kinterbasdb + +fdb +--- + +.. automodule:: sqlalchemy.dialects.firebird.fdb diff --git a/lib/sqlalchemy/dialects/firebird/fdb.py b/lib/sqlalchemy/dialects/firebird/fdb.py new file mode 100644 index 0000000000..e6ca170f77 --- /dev/null +++ b/lib/sqlalchemy/dialects/firebird/fdb.py @@ -0,0 +1,69 @@ +# firebird/fdb.py +# Copyright (C) 2005-2012 the SQLAlchemy authors and contributors +# +# This module is part of SQLAlchemy and is released under +# the MIT License: http://www.opensource.org/licenses/mit-license.php + +""" +fdb is a kinterbasdb compatible DBAPI for Firebird. + +Usage is currently the same as that of kinterbasdb, with the exception +of the connect string below. + +.. versionadded:: 0.8 - Support for the fdb Firebird driver. + +Status +------ + +The fdb dialect is new and not yet tested (can't get fdb to build). + +Connecting +----------- + +Connect string format:: + + firebird+fdb://user:password@host:port/path/to/db[?key=value&key=value...] + +""" + +from .kinterbasdb import FBDialect_kinterbasdb +from ... import util + +class FBDialect_fdb(FBDialect_kinterbasdb): + + @classmethod + def dbapi(cls): + return __import__('fdb') + + def create_connect_args(self, url): + opts = url.translate_connect_args(username='user') + if opts.get('port'): + opts['host'] = "%s/%s" % (opts['host'], opts['port']) + del opts['port'] + opts.update(url.query) + + util.coerce_kw_type(opts, 'type_conv', int) + + return ([], opts) + + def _get_server_version_info(self, connection): + """Get the version of the Firebird server used by a connection. + + Returns a tuple of (`major`, `minor`, `build`), three integers + representing the version of the attached server. + """ + + # This is the simpler approach (the other uses the services api), + # that for backward compatibility reasons returns a string like + # LI-V6.3.3.12981 Firebird 2.0 + # where the first version is a fake one resembling the old + # Interbase signature. + + isc_info_firebird_version = 103 + fbconn = connection.connection + + version = fbconn.db_info(isc_info_firebird_version) + + return self._parse_version_info(version) + +dialect = FBDialect_fdb \ No newline at end of file diff --git a/lib/sqlalchemy/dialects/firebird/kinterbasdb.py b/lib/sqlalchemy/dialects/firebird/kinterbasdb.py index a5dc821be1..47160f5ea2 100644 --- a/lib/sqlalchemy/dialects/firebird/kinterbasdb.py +++ b/lib/sqlalchemy/dialects/firebird/kinterbasdb.py @@ -5,11 +5,16 @@ # the MIT License: http://www.opensource.org/licenses/mit-license.php """ -The most common way to connect to a Firebird engine is implemented by -kinterbasdb__, currently maintained__ directly by the Firebird people. -The connection URL is of the form -``firebird[+kinterbasdb]://user:password@host:port/path/to/db[?key=value&key=value...]``. +Connecting +----------- + +Connect string format:: + + firebird+kinterbasdb://user:password@host:port/path/to/db[?key=value&key=value...] + +Arguments +---------- Kinterbasedb backend specific keyword arguments are: @@ -45,10 +50,9 @@ __ http://kinterbasdb.sourceforge.net/dist_docs/usage.html#adv_param_conv_dynami __ http://kinterbasdb.sourceforge.net/dist_docs/usage.html#special_issue_concurrency """ -from sqlalchemy.dialects.firebird.base import FBDialect, \ - FBCompiler, FBExecutionContext -from sqlalchemy import util, types as sqltypes -from sqlalchemy.util.compat import decimal +from .base import FBDialect, FBExecutionContext +from ... import util, types as sqltypes +from ...util.compat import decimal from re import match @@ -97,8 +101,7 @@ class FBDialect_kinterbasdb(FBDialect): @classmethod def dbapi(cls): - k = __import__('kinterbasdb') - return k + return __import__('kinterbasdb') def create_connect_args(self, url): opts = url.translate_connect_args(username='user')