views:

31

answers:

1

I'm using Java Scripting API to execute some external Python scripts from my Java application. The python scripts use sqlite3 module. Execution of the application is resulting in error

ImportError: No module named sqlite3

As I look into the Lib directory(which is in the classpath) of Jython, there's no sqlite3 module. Hence, my search begins and I found one _sqlite3.py file which is an implementation of javasqlite (http://bugs.jython.org/issue1682864). It's use produced more similar kind of errors.

Then I searched the original python's sqlite3 package(original directory) from the python's standard library location and placed it in the Jython's Lib folder. It then could not find imported _sqlite module which is the _sqlite.so library (actual C implementation).

So, now I need help.

A: 

I don't believe there is any way to use a CPython extension in Jython, so you're out of luck there.

There's a Java wrapper for SQLite here: http://www.zentus.com/sqlitejdbc/ This is not going to work quite like a Python database driver, so using it would require some adaptation.

Not fun, but perhaps you (or someone else) could write some Jython around it to produce a drop-in replacement for the sqlite3 module.

kwatford
Yes you are correct. So I threw away Jython and executed the Python scripts using ProcessBuilder classes. Worked like a charm. Thanks anyway.
kaychaks