how to deal with .mdb access files with python

后端 未结 6 1132
逝去的感伤
逝去的感伤 2020-12-08 00:45

Can someone point me in the right direction on how to open a .mdb file in python? I normally like including some code to start off a discussion, but I don\'t know where to s

6条回答
  •  情歌与酒
    2020-12-08 01:02

    In addition to bernie's response, I would add that it is possible to recover the schema of the database. The code below lists the tables (b[2] contains the name of the table).

    con = pyodbc.connect('DRIVER={};DBQ={};PWD={}'.format(DRV,MDB,PWD))
    cur = con.cursor()
    
    tables = list(cur.tables())
    
    print 'tables'
    for b in tables:
        print b
    

    The code below lists all the columns from all the tables:

    colDesc = list(cur.columns())
    

提交回复
热议问题