jyjdbc


Namejyjdbc JSON
Version 0.0.5 PyPI version JSON
download
home_pagehttps://hg.sr.ht/~clach04/jyjdbc
SummaryPure Jython (Python in the JVM) JDBC dbapi pep-249 driver
upload_time2024-09-06 23:24:04
maintainerChris Clark
docs_urlNone
authorChris Clark
requires_pythonNone
licenseLGPLv2.1
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            JyJDBC Pure Jython JDBC dbapi driver
========================================

--------

Overview
--------

https://pypi.org/project/jyjdbc/ is a pure Python pep-249 http://www.python.org/peps/pep-0249.html driver for JDBC usable under Jython.

Latest version available from https://hg.sr.ht/~clach04/jyjdbc

Original written for the Ingres JDBC driver, works with other drivers too.

Targets Jython 2.7.0, 2.5.3, and 2.5.2 (and also works with Jython 2.2).

CPython (and other Python implementations) can make use of JDBC
via a bridge to Jython. For example; RPyC, Pyro4, SPyRO, execnet, and SPIRO.
Use of a bridge may require additional security attention.

More information https://hg.sr.ht/~clach04/jyjdbc (previously https://bitbucket.org/clach04/jyjdbc/wiki/Home)

--------

Features
--------

-   Pure Python / Jython - no Java experience needed
-   No need for JDK, this driver can be extend with just a JRE
-   Only needs JRE, Jython, and JDBC driver for database
-   Better pep-249 compliance than zxJDBC, with a testsuite to prove it
-   Decimal data type support
-   Returns Java types when a Python type is not an option
-   Python developers can maintain it


Why?
----

I needed support for decimal data types which (in 2010) zxJDBC does not have
(nor do the other Python/JDBC solutions). I needed to create a number of
tests for the decimal type so this was a a major issue, I contributed
Decimal support to the IronPython driver but .NET has a limit of 28 decimal
places. JyJDBC has a simple internal structure, adding support for new
types is trivial.

Right now I recommed using jyjdbc instead of zxJDBC. Current weakness of
jyjdbc compared with zxJDBC is that row returning database procedures are
not yet implemented and a few types (Binary and ROWID) are not implemented
(Java types are returned instead).

A test suite is provided for JyJDBC as well as zxJDBC so the different
features/limitations/problems can be compared. There are tests for
Ingres and SQLite3.


## Installation

Either from PyPi or a checkout.

NOTE pip support is experimental and NOT recommended.

    java -jar jython-standalone-2.7.3.jar -m ensurepip
    # NOTE do not recommmend updating pip, especially under Microsoft Windows due to pip-20.3.4 errors related to missing winreg module
    java -jar jython-standalone-2.7.3.jar -m pip install jyjdbc

Demo
----

The following demos make use of the Ingres DBMS and the Ingres JDBC driver.
Connection is made to a database that always exists using Operating System
authentication (hence no username/password in the connect statement).
SELECT is against a table that always exists in all Ingres databases.


Regular Jython example
~~~~~~~~~~~~~~~~~~~~~~

This demo connects to a local Ingres DBMS as the current user.


    C:\>c:\jython2.5.1\jython.bat
    Jython 2.5.1 (Release_2_5_1:6813, Sep 26 2009, 13:47:54)
    [Java HotSpot(TM) Client VM (Sun Microsystems Inc.)] on java1.6.0_02
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import jyjdbc
    >>> con =jyjdbc.connect('iidbdb')  # II_SYSTEM already set, local connection
    >>> cur = con.cursor()
    >>> cur.execute('select * from iidbconstants')
    >>> print cur.description
    [(u'user_name', c, None, None, 32, 0, 0), (u'dba_name', c, None, None, 32, 0, 0), (u'system_owner', varchar, None, None, 32, 0, 0)]
    >>> print cur.fetchall()
    [(u'ingres                          ', u'$ingres                         ', u'$ingres                         ')]
    >>>

For more examples and using other databases see the project wiki
http://code.google.com/p/jyjdbc/wiki/Examples


CPython access to JDBC
~~~~~~~~~~~~~~~~~~~~~~

This demo uses RPyC version 3.1.0 from http://pypi.python.org/pypi/RPyC/

Jython starts rpyc_classic.py:


    jython rpyc_classic.py


CPython also uses RPyC, using the client:


    C:\>python.exe
    Python 2.4.4 (#71, Oct 18 2006, 08:34:43) [MSC v.1310 32 bit (Intel)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import rpyc
    >>> conn = rpyc.classic.connect("localhost")
    >>> jyjdbc = conn.modules.jyjdbc
    >>> con =jyjdbc.connect('iidbdb')  # II_SYSTEM already set (under RPC), local connection
    >>> cur = con.cursor()
    >>> cur.execute('select * from iidbconstants')
    >>> print cur.description
    [(u'user_name', c, None, None, 32, 0, 0), (u'dba_name', c, None, None, 32, 0, 0), (u'system_owner', varchar, None, None, 32, 0, 0)]
    >>> print cur.fetchall()
    [(u'ingres                          ', u'$ingres                         ', u'$ingres                         ')]



NOTES
-----

-   JDBC Time type does NOT support sub second values.
    This means that when Python datetime.time values are sent the time is
    truncated to the second. Similarly when ANSI time values are returned
    from the database if the JDBC driver returns a JDBC time, sub second
    accuracy is lost to truncation. This is how JDBC works.

-   Currently the driver is not 100% pep-249 compliant, but it is closer
    to 100% than zxJDBC. Patches for improvements are welcome.
    See test suite for details. NOTE the driver is being used everyday in
    the current state.

-   The test suite is incomplete, it could benefit from database procedures
    tests and support for other databses.

-   The driver has been tested with:

    -   Actian Avalanche from http://www.actian.com
    -   Actian Vector from http://www.actian.com
    -   Apache Derby from http://db.apache.org/derby/
        Version 10.8.1.2
    -   Ingres DBMS from http://www.actian.com
    -   H2 from http://www.h2database.com/
        Version 1.4.198 (2019-02-22)
    -   sqlite3
        -   sqlite-jdbc-3.7.2.jar from https://bitbucket.org/xerial/sqlite-jdbc/downloads
            (also see https://github.com/xerial/sqlite-jdbc).

    The driver was originally developed using Ingres.
    Patches for support of other drivers/servers are welcome,
    along with API improvements to improve PEP-249 compliance.

-   Support for Jython 2.2 is present, but due to the use of modules:

    -   Decimal
    -   datetime
    -   logging
    
    The Python 2.4 modules are needed. Python 2.5 support is
    the main focus of this driver but where possible support for older
    releases will be added. See "backports" notes in source. Or use
    a patched Jython 2.2 from https://bitbucket.org/clach04/jython/downloads
    
    I have jyjdbc running on a server with Jython 2.2.1 under JRE 1.5.0.

-   The setup.py script uses either setuptools or distutils. Distutils
    requires either either the standalone Jython jar file or a Standard
    Jython install (installing Core does not install distutils).

-   Building the documentation (via setup.py) requires docutils (and the
    docutils depedencies).

-   Running the test suite requires dbapi20 / dbapi-compliance. There are
    other testsuites and it would be good to have jyjdbc running with those.
    For more information about dbapi20 see:

    -   https://web.archive.org/web/20200608201110/http://stuartbishop.net/Software/DBAPI20TestSuite/
    -   https://launchpad.net/dbapi-compliance

    A known working copy of dbapi-compliance (aka dbapi20) is available
    from https://bitbucket.org/clach04/dbapi-compliance/overview

    It would be useful to add support for some ORMs and make use of the ORM
    test suite, for example SQLAlchemy has comprehensive test suite.

    For any changes, please ensure the test suite runs clean using the H2 test
    suite.

            

Raw data

            {
    "_id": null,
    "home_page": "https://hg.sr.ht/~clach04/jyjdbc",
    "name": "jyjdbc",
    "maintainer": "Chris Clark",
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": null,
    "author": "Chris Clark",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/33/8e/c59c08fbb53cb8ceb11786328d8a6ebc4881bb94793df6694897d6f5d1d5/jyjdbc-0.0.5.tar.gz",
    "platform": "any",
    "description": "JyJDBC Pure Jython JDBC dbapi driver\r\n========================================\r\n\r\n--------\r\n\r\nOverview\r\n--------\r\n\r\nhttps://pypi.org/project/jyjdbc/ is a pure Python pep-249 http://www.python.org/peps/pep-0249.html driver for JDBC usable under Jython.\r\n\r\nLatest version available from https://hg.sr.ht/~clach04/jyjdbc\r\n\r\nOriginal written for the Ingres JDBC driver, works with other drivers too.\r\n\r\nTargets Jython 2.7.0, 2.5.3, and 2.5.2 (and also works with Jython 2.2).\r\n\r\nCPython (and other Python implementations) can make use of JDBC\r\nvia a bridge to Jython. For example; RPyC, Pyro4, SPyRO, execnet, and SPIRO.\r\nUse of a bridge may require additional security attention.\r\n\r\nMore information https://hg.sr.ht/~clach04/jyjdbc (previously https://bitbucket.org/clach04/jyjdbc/wiki/Home)\r\n\r\n--------\r\n\r\nFeatures\r\n--------\r\n\r\n-   Pure Python / Jython - no Java experience needed\r\n-   No need for JDK, this driver can be extend with just a JRE\r\n-   Only needs JRE, Jython, and JDBC driver for database\r\n-   Better pep-249 compliance than zxJDBC, with a testsuite to prove it\r\n-   Decimal data type support\r\n-   Returns Java types when a Python type is not an option\r\n-   Python developers can maintain it\r\n\r\n\r\nWhy?\r\n----\r\n\r\nI needed support for decimal data types which (in 2010) zxJDBC does not have\r\n(nor do the other Python/JDBC solutions). I needed to create a number of\r\ntests for the decimal type so this was a a major issue, I contributed\r\nDecimal support to the IronPython driver but .NET has a limit of 28 decimal\r\nplaces. JyJDBC has a simple internal structure, adding support for new\r\ntypes is trivial.\r\n\r\nRight now I recommed using jyjdbc instead of zxJDBC. Current weakness of\r\njyjdbc compared with zxJDBC is that row returning database procedures are\r\nnot yet implemented and a few types (Binary and ROWID) are not implemented\r\n(Java types are returned instead).\r\n\r\nA test suite is provided for JyJDBC as well as zxJDBC so the different\r\nfeatures/limitations/problems can be compared. There are tests for\r\nIngres and SQLite3.\r\n\r\n\r\n## Installation\r\n\r\nEither from PyPi or a checkout.\r\n\r\nNOTE pip support is experimental and NOT recommended.\r\n\r\n    java -jar jython-standalone-2.7.3.jar -m ensurepip\r\n    # NOTE do not recommmend updating pip, especially under Microsoft Windows due to pip-20.3.4 errors related to missing winreg module\r\n    java -jar jython-standalone-2.7.3.jar -m pip install jyjdbc\r\n\r\nDemo\r\n----\r\n\r\nThe following demos make use of the Ingres DBMS and the Ingres JDBC driver.\r\nConnection is made to a database that always exists using Operating System\r\nauthentication (hence no username/password in the connect statement).\r\nSELECT is against a table that always exists in all Ingres databases.\r\n\r\n\r\nRegular Jython example\r\n~~~~~~~~~~~~~~~~~~~~~~\r\n\r\nThis demo connects to a local Ingres DBMS as the current user.\r\n\r\n\r\n    C:\\>c:\\jython2.5.1\\jython.bat\r\n    Jython 2.5.1 (Release_2_5_1:6813, Sep 26 2009, 13:47:54)\r\n    [Java HotSpot(TM) Client VM (Sun Microsystems Inc.)] on java1.6.0_02\r\n    Type \"help\", \"copyright\", \"credits\" or \"license\" for more information.\r\n    >>> import jyjdbc\r\n    >>> con =jyjdbc.connect('iidbdb')  # II_SYSTEM already set, local connection\r\n    >>> cur = con.cursor()\r\n    >>> cur.execute('select * from iidbconstants')\r\n    >>> print cur.description\r\n    [(u'user_name', c, None, None, 32, 0, 0), (u'dba_name', c, None, None, 32, 0, 0), (u'system_owner', varchar, None, None, 32, 0, 0)]\r\n    >>> print cur.fetchall()\r\n    [(u'ingres                          ', u'$ingres                         ', u'$ingres                         ')]\r\n    >>>\r\n\r\nFor more examples and using other databases see the project wiki\r\nhttp://code.google.com/p/jyjdbc/wiki/Examples\r\n\r\n\r\nCPython access to JDBC\r\n~~~~~~~~~~~~~~~~~~~~~~\r\n\r\nThis demo uses RPyC version 3.1.0 from http://pypi.python.org/pypi/RPyC/\r\n\r\nJython starts rpyc_classic.py:\r\n\r\n\r\n    jython rpyc_classic.py\r\n\r\n\r\nCPython also uses RPyC, using the client:\r\n\r\n\r\n    C:\\>python.exe\r\n    Python 2.4.4 (#71, Oct 18 2006, 08:34:43) [MSC v.1310 32 bit (Intel)] on win32\r\n    Type \"help\", \"copyright\", \"credits\" or \"license\" for more information.\r\n    >>> import rpyc\r\n    >>> conn = rpyc.classic.connect(\"localhost\")\r\n    >>> jyjdbc = conn.modules.jyjdbc\r\n    >>> con =jyjdbc.connect('iidbdb')  # II_SYSTEM already set (under RPC), local connection\r\n    >>> cur = con.cursor()\r\n    >>> cur.execute('select * from iidbconstants')\r\n    >>> print cur.description\r\n    [(u'user_name', c, None, None, 32, 0, 0), (u'dba_name', c, None, None, 32, 0, 0), (u'system_owner', varchar, None, None, 32, 0, 0)]\r\n    >>> print cur.fetchall()\r\n    [(u'ingres                          ', u'$ingres                         ', u'$ingres                         ')]\r\n\r\n\r\n\r\nNOTES\r\n-----\r\n\r\n-   JDBC Time type does NOT support sub second values.\r\n    This means that when Python datetime.time values are sent the time is\r\n    truncated to the second. Similarly when ANSI time values are returned\r\n    from the database if the JDBC driver returns a JDBC time, sub second\r\n    accuracy is lost to truncation. This is how JDBC works.\r\n\r\n-   Currently the driver is not 100% pep-249 compliant, but it is closer\r\n    to 100% than zxJDBC. Patches for improvements are welcome.\r\n    See test suite for details. NOTE the driver is being used everyday in\r\n    the current state.\r\n\r\n-   The test suite is incomplete, it could benefit from database procedures\r\n    tests and support for other databses.\r\n\r\n-   The driver has been tested with:\r\n\r\n    -   Actian Avalanche from http://www.actian.com\r\n    -   Actian Vector from http://www.actian.com\r\n    -   Apache Derby from http://db.apache.org/derby/\r\n        Version 10.8.1.2\r\n    -   Ingres DBMS from http://www.actian.com\r\n    -   H2 from http://www.h2database.com/\r\n        Version 1.4.198 (2019-02-22)\r\n    -   sqlite3\r\n        -   sqlite-jdbc-3.7.2.jar from https://bitbucket.org/xerial/sqlite-jdbc/downloads\r\n            (also see https://github.com/xerial/sqlite-jdbc).\r\n\r\n    The driver was originally developed using Ingres.\r\n    Patches for support of other drivers/servers are welcome,\r\n    along with API improvements to improve PEP-249 compliance.\r\n\r\n-   Support for Jython 2.2 is present, but due to the use of modules:\r\n\r\n    -   Decimal\r\n    -   datetime\r\n    -   logging\r\n    \r\n    The Python 2.4 modules are needed. Python 2.5 support is\r\n    the main focus of this driver but where possible support for older\r\n    releases will be added. See \"backports\" notes in source. Or use\r\n    a patched Jython 2.2 from https://bitbucket.org/clach04/jython/downloads\r\n    \r\n    I have jyjdbc running on a server with Jython 2.2.1 under JRE 1.5.0.\r\n\r\n-   The setup.py script uses either setuptools or distutils. Distutils\r\n    requires either either the standalone Jython jar file or a Standard\r\n    Jython install (installing Core does not install distutils).\r\n\r\n-   Building the documentation (via setup.py) requires docutils (and the\r\n    docutils depedencies).\r\n\r\n-   Running the test suite requires dbapi20 / dbapi-compliance. There are\r\n    other testsuites and it would be good to have jyjdbc running with those.\r\n    For more information about dbapi20 see:\r\n\r\n    -   https://web.archive.org/web/20200608201110/http://stuartbishop.net/Software/DBAPI20TestSuite/\r\n    -   https://launchpad.net/dbapi-compliance\r\n\r\n    A known working copy of dbapi-compliance (aka dbapi20) is available\r\n    from https://bitbucket.org/clach04/dbapi-compliance/overview\r\n\r\n    It would be useful to add support for some ORMs and make use of the ORM\r\n    test suite, for example SQLAlchemy has comprehensive test suite.\r\n\r\n    For any changes, please ensure the test suite runs clean using the H2 test\r\n    suite.\r\n",
    "bugtrack_url": null,
    "license": "LGPLv2.1",
    "summary": "Pure Jython (Python in the JVM) JDBC dbapi pep-249 driver",
    "version": "0.0.5",
    "project_urls": {
        "Homepage": "https://hg.sr.ht/~clach04/jyjdbc"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "338ec59c08fbb53cb8ceb11786328d8a6ebc4881bb94793df6694897d6f5d1d5",
                "md5": "d422d599c510fc9a945de2f3434a6f2a",
                "sha256": "41958dc075122cf81c580120bb844000d87f233a7fe2fc05e4272a695dc8e1cd"
            },
            "downloads": -1,
            "filename": "jyjdbc-0.0.5.tar.gz",
            "has_sig": false,
            "md5_digest": "d422d599c510fc9a945de2f3434a6f2a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 36421,
            "upload_time": "2024-09-06T23:24:04",
            "upload_time_iso_8601": "2024-09-06T23:24:04.088504Z",
            "url": "https://files.pythonhosted.org/packages/33/8e/c59c08fbb53cb8ceb11786328d8a6ebc4881bb94793df6694897d6f5d1d5/jyjdbc-0.0.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-06 23:24:04",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "jyjdbc"
}
        
Elapsed time: 0.52634s