平台: Windows 7 (64位),Jython版本2.7.10“最终版本”。
目前使用java.sql类访问MS访问数据库。
在将来的某个时候,我想转移到Linux。在将来的某个时候我想搬到MySQL/MariaDB..。
我认为用一种更多的Pythonic方式会更好,而Pyodbc似乎是最好的选择。
这是我使用pip安装它的尝试:
D:\apps\jython2.7.0\bin>pip install pyodbc
Downloading/unpacking pyodbc
Downloading pyodbc-3.0.10.tar.gz (68kB): 68kB downloaded
Running setup.py (path:C:\Users\Chris\AppData\Local\Temp\pip_build_Chris\pyodb
c\setup.py) egg_info for package pyodbc
warning: no files found matching 'tests\*'
warning: no files found matching 'README.rst'
Installing collected packages: pyodbc
Running setup.py install for pyodbc
building 'pyodbc' extension
error: Compiling extensions is not supported on Jython
Complete output from command D:\apps\jython2.7.0\bin\jython.exe -c "import s
etuptools, tokenize;__file__='C:\\Users\\Chris\\AppData\\Local\\Temp\\pip_build_
Chris\\pyodbc\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).
read().replace('\r\n', '\n'), __file__, 'exec'))" install --record C:\Users\Chri
s\AppData\Local\Temp\pip-xb4a39-record\install-record.txt --single-version-exter
nally-managed --compile:
running install
running build
running build_ext
building 'pyodbc' extension
error: Compiling extensions is not supported on Jython
----------------------------------------
Cleaning up...
←[31mCommand "D:\apps\jython2.7.0\bin\jython.exe -c "import setuptools, tokenize
;__file__='C:\\Users\\Chris\\AppData\\Local\\Temp\\pip_build_Chris\\pyodbc\\setu
p.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\
n', '\n'), __file__, 'exec'))" install --record C:\Users\Chris\AppData\Local\Tem
p\pip-xb4a39-record\install-record.txt --single-version-externally-managed --com
pile" failed with error code 1 in C:\Users\Chris\AppData\Local\Temp\pip_build_Ch
ris\pyodbc
←[0m←[31mStoring debug log for failure in C:\Users\Chris\.pip\pip.log
←[0m
D:\apps\jython2.7.0\bin>有人知道这件事是否可以补救吗?
对于使用Jython对dbase的Pythonic访问,有人有其他的建议吗?
发布于 2015-10-10 13:04:02
当您迁移到Linux时,您将不再有可用的驱动程序(它仅限于Windows)。在非Windows平台上使用Access数据库还有其他ODBC选项,但它们可能不太理想。
对于真正的跨平台解决方案,您可以将Jython与UCanAccess JDBC驱动程序结合使用,如下所示:
发布于 2015-10-10 11:49:47
既然您正在运行Jython,那么您就进入了Java世界。这就是JDBC;ODBC用于C (CPython)世界中的项目。而不是使用pyodbc,您需要这样做:
http://www.jython.org/archive/21/docs/zxjdbc.html
除非您使用的是CPython (“标准默认”版本),否则pyodbc将无法工作。您有什么特别的理由使用Jython吗?大多数人只在真正需要JVM或特定的JAR/WAR时才使用它。
https://stackoverflow.com/questions/33053343
复制相似问题