Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1# connectors/zxJDBC.py 

2# Copyright (C) 2005-2020 the SQLAlchemy authors and contributors 

3# <see AUTHORS file> 

4# 

5# This module is part of SQLAlchemy and is released under 

6# the MIT License: http://www.opensource.org/licenses/mit-license.php 

7 

8import sys 

9 

10from . import Connector 

11 

12 

13class ZxJDBCConnector(Connector): 

14 driver = "zxjdbc" 

15 

16 supports_sane_rowcount = False 

17 supports_sane_multi_rowcount = False 

18 

19 supports_unicode_binds = True 

20 supports_unicode_statements = sys.version > "2.5.0+" 

21 description_encoding = None 

22 default_paramstyle = "qmark" 

23 

24 jdbc_db_name = None 

25 jdbc_driver_name = None 

26 

27 @classmethod 

28 def dbapi(cls): 

29 from com.ziclix.python.sql import zxJDBC 

30 

31 return zxJDBC 

32 

33 def _driver_kwargs(self): 

34 """Return kw arg dict to be sent to connect().""" 

35 return {} 

36 

37 def _create_jdbc_url(self, url): 

38 """Create a JDBC url from a :class:`~sqlalchemy.engine.url.URL`""" 

39 return "jdbc:%s://%s%s/%s" % ( 

40 self.jdbc_db_name, 

41 url.host, 

42 url.port is not None and ":%s" % url.port or "", 

43 url.database, 

44 ) 

45 

46 def create_connect_args(self, url): 

47 opts = self._driver_kwargs() 

48 opts.update(url.query) 

49 return [ 

50 [ 

51 self._create_jdbc_url(url), 

52 url.username, 

53 url.password, 

54 self.jdbc_driver_name, 

55 ], 

56 opts, 

57 ] 

58 

59 def is_disconnect(self, e, connection, cursor): 

60 if not isinstance(e, self.dbapi.ProgrammingError): 

61 return False 

62 e = str(e) 

63 return "connection is closed" in e or "cursor is closed" in e 

64 

65 def _get_server_version_info(self, connection): 

66 # use connection.connection.dbversion, and parse appropriately 

67 # to get a tuple 

68 raise NotImplementedError()