dibbler/sqlalchemy/connectors/zxJDBC.py

61 lines
1.8 KiB
Python
Raw Normal View History

2017-04-15 18:27:12 +02:00
# connectors/zxJDBC.py
# Copyright (C) 2005-2017 the SQLAlchemy authors and contributors
# <see AUTHORS file>
#
# This module is part of SQLAlchemy and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
2010-05-07 19:33:49 +02:00
import sys
2017-04-15 18:27:12 +02:00
from . import Connector
2010-05-07 19:33:49 +02:00
class ZxJDBCConnector(Connector):
driver = 'zxjdbc'
2017-04-15 18:27:12 +02:00
2010-05-07 19:33:49 +02:00
supports_sane_rowcount = False
supports_sane_multi_rowcount = False
2017-04-15 18:27:12 +02:00
2010-05-07 19:33:49 +02:00
supports_unicode_binds = True
supports_unicode_statements = sys.version > '2.5.0+'
description_encoding = None
default_paramstyle = 'qmark'
2017-04-15 18:27:12 +02:00
2010-05-07 19:33:49 +02:00
jdbc_db_name = None
jdbc_driver_name = None
2017-04-15 18:27:12 +02:00
2010-05-07 19:33:49 +02:00
@classmethod
def dbapi(cls):
from com.ziclix.python.sql import zxJDBC
return zxJDBC
def _driver_kwargs(self):
"""Return kw arg dict to be sent to connect()."""
return {}
2017-04-15 18:27:12 +02:00
2010-05-07 19:33:49 +02:00
def _create_jdbc_url(self, url):
"""Create a JDBC url from a :class:`~sqlalchemy.engine.url.URL`"""
return 'jdbc:%s://%s%s/%s' % (self.jdbc_db_name, url.host,
2017-04-15 18:27:12 +02:00
url.port is not None
and ':%s' % url.port or '',
2010-05-07 19:33:49 +02:00
url.database)
2017-04-15 18:27:12 +02:00
2010-05-07 19:33:49 +02:00
def create_connect_args(self, url):
opts = self._driver_kwargs()
opts.update(url.query)
2017-04-15 18:27:12 +02:00
return [
[self._create_jdbc_url(url),
url.username, url.password,
self.jdbc_driver_name],
opts]
2010-05-07 19:33:49 +02:00
2017-04-15 18:27:12 +02:00
def is_disconnect(self, e, connection, cursor):
2010-05-07 19:33:49 +02:00
if not isinstance(e, self.dbapi.ProgrammingError):
return False
e = str(e)
return 'connection is closed' in e or 'cursor is closed' in e
def _get_server_version_info(self, connection):
# use connection.connection.dbversion, and parse appropriately
# to get a tuple
raise NotImplementedError()