Query for Access mdb can't be run in Python on Linux

824 Views Asked by At

I want to read a *.mdb database in odoo and import some data to odoo but I cannot read some fields.

In *.mdb I have 2 tables
first table is USERINFO with fields: SSN, Name, USERID
second table is CHECKINOUT with fields: USERID, CHECKTIME, CHECKTYPE

I use mdbtools and it runs well when I make this query

query1 = 'SELECT CHECKTIME,CHECKTYPE FROM CHECKINOUT'

The data I want is out.

But it errors when I run these two queries.

query2 = 'SELECT USERID,CHECKTIME FROM CHECKINOUT'

pyodbc.Error: ('HY000', 'The driver did not supply an error!')

it's look the problem in in "USERID" field

and in the other query

query3 = """
SELECT c.CHECKTIME, c.CHECKTYPE, u.SSN, u.`Name`, u.USERID 
FROM CHECKINOUT c, USERINFO u  
WHERE c.USERID = u.USERID """

Error at Line : syntax error near c.CHECKTIME syntax error near c.CHECKTIME Got no result for 'SELECT c.CHECKTIME, c.CHECKTYPE, u.SSN FROM CHECKINOUT c, USERINFO u WHERE c.USERID=u.USERID; ' command

pyodbc.OperationalError: ('08001', "[08001] Couldn't parse SQL\n (1) (SQLExecDirectW)")

The query runs well in the DBeaver, but didn't running well in python.

0

There are 0 best solutions below