What do I need to read Microsoft Access databases using Python?

后端 未结 12 2186
面向向阳花
面向向阳花 2020-11-27 15:59

How can I access Microsoft Access databases in Python? With SQL?

I\'d prefere a solution that works with Linux, but I could also settle for Windows.

I only r

相关标签:
12条回答
  • 2020-11-27 16:26

    The way I connect Python to MS Access under Windows is by using this way: Connect to MS Access with Python. Maybe you can find some trouble on Win 7, so I found a solution: Solving a connection between MS Access and Python on Windows 7

    I haven't tried connecting under Linux!

    0 讨论(0)
  • 2020-11-27 16:27

    If you sync your database to the web using EQL Data, then you can query the contents of your Access tables using JSON or YAML: http://eqldata.com/kb/1002.

    That article is about PHP, but it would work just as well in Python.

    0 讨论(0)
  • 2020-11-27 16:28

    I've used PYODBC to connect succesfully to an MS Access db - on Windows though. Install was easy, usage is fairly simple, you just need to set the right connection string (the one for MS Access is given in the list) and of you go with the examples.

    0 讨论(0)
  • 2020-11-27 16:28

    Personally, I have never been able to get MDB Tools (along with related ODBC stuff like unixODBC) to work properly with Python or PHP under Linux, even after numerous attempts. I just tried the instructions in the other answer to this question here and all I got was "Segmentation fault (core dumped)".

    However, I did get the UCanAccess JDBC driver to read both .mdb and .accdb files on Linux from either Jython or CPython+JayDeBeApi. For detailed instructions on how I set it up under Ubuntu 14.04 LTS see my other answer here.

    0 讨论(0)
  • 2020-11-27 16:33

    Old question, but I thought I'd post a pypyodbc alternative suggestion for Windows: ADO. Turns out, it's really easy to get at Access databases, Excel spreadsheets and anything else with a modern (as opposed to old-school ODBC) driver via COM.

    Check out the following articles:

    • http://www.mayukhbose.com/python/ado/index.php
    • http://www.markcarter.me.uk/computing/python/ado.html
    • http://www.ecp.cc/ado_examples.shtml
    0 讨论(0)
  • 2020-11-27 16:35

    On Linux, MDBTools is your only chance as of now. [disputed]

    On Windows, you can deal with mdb files with pypyodbc.

    To create an Access mdb file:

    import pypyodbc
    pypyodbc.win_create_mdb( "D:\\Your_MDB_file_path.mdb" )
    

    Here is an Hello World script that fully demostate pypyodbc's Access support functions.

    Disclaimer: I'm the developer of pypyodbc.

    0 讨论(0)
提交回复
热议问题