Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[support] accessing local .accdb file in Linux 32bit #76

Open
answerquest opened this issue May 3, 2018 · 0 comments
Open

[support] accessing local .accdb file in Linux 32bit #76

answerquest opened this issue May 3, 2018 · 0 comments

Comments

@answerquest
Copy link

Hi, I'm trying to read a .accdb file in my 32-bit Lubuntu 16.04 system (analogous to Ubuntu). This file is from another system. There's no ODBC server etc running.. the data is in one file and I want to access it.

I'm seeing simple commands shared on stackoverflow etc for creating these files.

But then the solutions straightaway jump into complicated server connections for reading databases in some server. I'm not finding anything for reading tables from a .accdb file.

Could someone help out here please? The closest I've gotten is: https://stackoverflow.com/questions/25820698/how-do-i-import-an-accdb-file-into-python-and-use-the-data but it seems that will work for windows and not linux.

I also followed the steps given here: https://code.google.com/archive/p/pypyodbc/wikis/Linux_ODBC_in_3_steps.wiki

Again it ends with giving some server connection. I don't have anything in any server, I have a .accdb file. Sharing my code and error:

import pypyodbc
pypyodbc.lowercase = False
dbFile = 'MyFarmerOrders-02Apr.accdb'
conn = pypyodbc.connect(
    r"Driver={FreeTDS};" +
    r"Dbq=" + dbFile)
cur = conn.cursor()

Error:

Error                                     Traceback (most recent call last)
<ipython-input-6-8eec40246f17> in <module>()
      3 conn = pypyodbc.connect(
      4     r"Driver={FreeTDS};" +
----> 5     r"Dbq=" + dbFile)
      6 cur = conn.cursor()

~/.local/lib/python3.5/site-packages/pypyodbc.py in __init__(self, connectString, autocommit, ansi, timeout, unicode_results, readonly, **kargs)
   2452 
   2453 
-> 2454         self.connect(connectString, autocommit, ansi, timeout, unicode_results, readonly)
   2455 
   2456     def set_connection_timeout(self,connection_timeout):

~/.local/lib/python3.5/site-packages/pypyodbc.py in connect(self, connectString, autocommit, ansi, timeout, unicode_results, readonly)
   2505         else:
   2506             ret = odbc_func(self.dbc_h, 0, c_connectString, len(self.connectString), None, 0, None, SQL_DRIVER_NOPROMPT)
-> 2507         check_success(self, ret)
   2508 
   2509 

~/.local/lib/python3.5/site-packages/pypyodbc.py in check_success(ODBC_obj, ret)
   1007             ctrl_err(SQL_HANDLE_STMT, ODBC_obj.stmt_h, ret, ODBC_obj.ansi)
   1008         elif isinstance(ODBC_obj, Connection):
-> 1009             ctrl_err(SQL_HANDLE_DBC, ODBC_obj.dbc_h, ret, ODBC_obj.ansi)
   1010         else:
   1011             ctrl_err(SQL_HANDLE_ENV, ODBC_obj, ret, False)

~/.local/lib/python3.5/site-packages/pypyodbc.py in ctrl_err(ht, h, val_ret, ansi)
    983                 raise OperationalError(state,err_text)
    984             elif state[:2] in (raw_s('IM'),raw_s('HY')):
--> 985                 raise Error(state,err_text)
    986             else:
    987                 raise DatabaseError(state,err_text)
Error: ('IM002', '[IM002] [unixODBC][Driver Manager]Data source name not found, and no default driver specified')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant