Package: ha_JayDeBeApi
The JayDeBeApi module allows you to connect from Python code to
databases using JavaJDBC. It provides a
PythonDB-APIv2.0 to that database.It works on ordinary Python (cPython) using theJPypeJava
integration or onJythonto make use of
the Java JDBC driver.In contrast to zxJDBC from the Jython project JayDeBeApi let’s you
access a database with Jython AND Python with only minor code
modifications. JayDeBeApi’s future goal is to provide a unique and
fast interface to different types of JDBC-Drivers through a flexible
plug-in mechanism.ContentsInstallUsageSupported databasesContributingLicenseChangelogTo doInstallYou can get and install JayDeBeApi withpip$ pip install JayDeBeApiIf you want to install JayDeBeApi in Jython make sure to have pip or
EasyInstall available for it.Or you can get a copy of the source by cloning from theJayDeBeApi
github projectand install
with$ python setup.py installor if you are using Jython use$ jython setup.py installIt has been tested with Jython 2.7.0.If you are using cPython ensure that you have installedJPypeproperly. It has been tested with JPype1 0.5.7. Older JPype
installations may cause problems.UsageBasically you just import thejaydebeapiPython module and execute
theconnectmethod. This gives you aDB-APIconform connection to
the database.The first argument toconnectis the name of the Java driver
class. The second argument is a string with the JDBC connection
URL. Third you can optionally supply a sequence consisting of user and
password or alternatively a dictionary containing arguments that are
internally passed as properties to the JavaDriverManager.getConnectionmethod. See the Javadoc ofDriverManagerclass for details.The next parameter toconnectis optional as well and specifies
the jar-Files of the driver if your classpath isn’t set up
sufficiently yet. The classpath set inCLASSPATHenvironment
variable will be honored. See the documentation of your Java runtime
environment.Here is an example:>>> import jaydebeapi
>>> conn = jaydebeapi.connect("org.hsqldb.jdbcDriver",
...                           "jdbc:hsqldb:mem:.",
...                           ["SA", ""],
...                           "/path/to/hsqldb.jar",)
>>> curs = conn.cursor()
>>> curs.execute('create table CUSTOMER'
...                '("CUST_ID" INTEGER not null,'
...                ' "NAME" VARCHAR not null,'
...                ' primary key ("CUST_ID"))'
...             )
>>> curs.execute("insert into CUSTOMER values (1, 'John')")
>>> curs.execute("select * from CUSTOMER")
>>> curs.fetchall()
[(1, u'John')]
>>> curs.close()
>>> conn.close()An alternative way to establish connection using connection
properties:>>> conn = jaydebeapi.connect("org.hsqldb.jdbcDriver",
...                           "jdbc:hsqldb:mem:.",
...                           {'user': "SA", 'password': "",
...                            'other_property': "foobar"},
...                           "/path/to/hsqldb.jar",)If you’re having trouble getting this work check if yourJAVA_HOMEenvironmentvariable is set correctly. For example I have to set it on
my Ubuntu machine like this$ JAVA_HOME=/usr/lib/jvm/java-8-openjdk pythonSupported databasesIn theoryevery database with a suitable JDBC driver should work. It
is confirmed to work with the following databases:SQLiteHypersonic SQL (HSQLDB)IBM DB2IBM DB2 for mainframesOracleTeradata DBNetezzaMimer DBMicrosoft SQL ServerMySQLPostgreSQLmany more…ContributingPlease submitbugs and patches. All contributors
will be acknowledged. Thanks!LicenseJayDeBeApi is released under the GNU Lesser General Public license
(LGPL). See the fileCOPYINGandCOPYING.LESSERin the
distribution for details.ChangelogNext version - unreleased1.1.1 - 2017-03-21Don’t fail on dates before 1900 on Python < 3.1.1.0 - 2017-03-19Support BIT and TINYINT type mappings (thanks @Mokubyow for
reporting the issue).1.0.0 - 2017-01-10Allow for db properties to be passed to the connect
method.Probably incompatible to code based on previous
versions.See documentation of the connect method. (Thanks
@testlnord for you efforts and the patience.)New major version due to possible api incompatibility.0.2.0 - 2015-04-26Python 3 support (requires JPype1 >= 0.6.0).0.1.6 - 2015-04-10Fix Jython handling of Java exceptions that don’t subclass python ExceptionEnrich exceptions with message from java SQLExceptionsBe more specific about DB API exceptions: Distinguish DatabaseError and
InterfaceError.Fix typo LONGNARCHAR vs LONGVARCHAR (thanks @datdo for reporting #4)0.1.5 - 2015-03-02Add version number to module.Improve robustness of java to python type conversion.Support Time type.Add DB-API compliant exception handling.Minor documentation improvements.Some development related changes (Host project at github, use
Travis CI, use JPype1 for tests).0.1.4 - 2013-10-29More convenient way to setup Java classpath.Important notecheck the changes to theconnectmethod and adapt your code.HonorCLASSPATHif used in JPype mode.Set.rowcountproperly.Changed signature of.setoutputsize()to be DB-API compliant.0.1.3 - 2011-01-27FixedDB-APIviolation: Usecurs.execute('foo?',(bar, baz))instead ofcurs.execute('foo?',bar, baz).Free resources afterexecutemanycall.Improved type handling. Initial support for BLOB columns.0.1.2 - 2011-01-25easy_install JayDeBeApishould really work.0.1.1 - 2010-12-12Fixed bug #688290 “NULL values with converters error on fetch”.Fixed bug #684909 “Selecting ROWIDs errors out on fetch”.0.1 - 2010-08-10Initial release.To doExtract Java calls to separate Java methods to increase performance.Check ifhttps://code.launchpad.net/dbapi-compliancecan help making
JayDeBeApi more DB-API compliant.Test it on different databases and provide a flexible db specific
pluign mechanism.SQLAlchemy modules (separate project)