1

Platform: Windows 7 (64 bit), Jython version 2.7.10 "final release".
Currently using the java.sql classes to access MS Access dbases.

At some point in the future I want to move to Linux. At some point in the future I want to move to MySQL/MariaDB...

I thought it'd be good to use a more Pythonic way, and it seemed Pyodbc might be the way to go.

This was my attempt to use pip to install it:

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>

Anyone know whether this can be remedied/worked around?
Anyone have an alternative suggestion for Pythonic access to dbases using Jython?

mike rodent
  • 14,126
  • 11
  • 103
  • 157

2 Answers2

2

When you move to Linux you will no longer have the Microsoft Access ODBC driver available (it is Windows-only). There are other ODBC options for working with Access databases on non-Windows platforms but they can be less than ideal.

For a truly cross-platform solution you could use Jython with the UCanAccess JDBC driver as described in another answer here:

Read an Access database in Python on non-Windows platform (Linux or Mac)

Community
  • 1
  • 1
Gord Thompson
  • 116,920
  • 32
  • 215
  • 418
1

Since you're running Jython, you're in the Java world. That'd be JDBC; ODBC is for projects in the C (CPython) world. Instead of using pyodbc, you'll need this:

http://www.jython.org/archive/21/docs/zxjdbc.html

pyodbc won't work unless you're using CPython (the "standard default" version). Is there any reason in particular you're using Jython? Most people only use it if they really need the JVM or particular JARs / WARs.

FlipperPA
  • 13,607
  • 4
  • 39
  • 71
  • Thanks for that link... I'm totally committed to Jython because that way you get the best of both worlds. Plus genuine concurrency... Plus all the thousands of beautifully engineered Java classes... plus all the libraries, utility classes, etc. etc., out in both the Java and Python ecosystems. I just hope the geniuses at Jython will eventually bring out Jython 3 sooner or later! – mike rodent Oct 10 '15 at 13:05