zxjdbc.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # postgresql/zxjdbc.py
  2. # Copyright (C) 2005-2017 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. """
  8. .. dialect:: postgresql+zxjdbc
  9. :name: zxJDBC for Jython
  10. :dbapi: zxjdbc
  11. :connectstring: postgresql+zxjdbc://scott:tiger@localhost/db
  12. :driverurl: http://jdbc.postgresql.org/
  13. """
  14. from ...connectors.zxJDBC import ZxJDBCConnector
  15. from .base import PGDialect, PGExecutionContext
  16. class PGExecutionContext_zxjdbc(PGExecutionContext):
  17. def create_cursor(self):
  18. cursor = self._dbapi_connection.cursor()
  19. cursor.datahandler = self.dialect.DataHandler(cursor.datahandler)
  20. return cursor
  21. class PGDialect_zxjdbc(ZxJDBCConnector, PGDialect):
  22. jdbc_db_name = 'postgresql'
  23. jdbc_driver_name = 'org.postgresql.Driver'
  24. execution_ctx_cls = PGExecutionContext_zxjdbc
  25. supports_native_decimal = True
  26. def __init__(self, *args, **kwargs):
  27. super(PGDialect_zxjdbc, self).__init__(*args, **kwargs)
  28. from com.ziclix.python.sql.handler import PostgresqlDataHandler
  29. self.DataHandler = PostgresqlDataHandler
  30. def _get_server_version_info(self, connection):
  31. parts = connection.connection.dbversion.split('.')
  32. return tuple(int(x) for x in parts)
  33. dialect = PGDialect_zxjdbc