sqlite3 module for Jython

若如初见. 提交于 2019-12-07 03:01:12

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/3875212/sqlite3-module-for-jython

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!