Query crashes MS Access

前端 未结 4 1369
你的背包
你的背包 2021-01-22 02:39

THE TASK: I am in the process of migrating a DB from MS Access to Maximizer. In order to do this I must take 64 tables in MS ACCESS and merge them into one. The

4条回答
  •  孤街浪徒
    2021-01-22 03:41

    I agree with FrustratedWithFormsDesigner. #2 seems the simplest method.

    Here is some tested code if you decide to go that route (requires pyodbc):

    import csv
    import pyodbc
    
    MDB = 'c:/path/to/my.mdb'
    DRV = '{Microsoft Access Driver (*.mdb)}'
    PWD = 'mypassword'
    
    conn = pyodbc.connect('DRIVER=%s;DBQ=%s;PWD=%s' % (DRV,MDB,PWD))
    curs = conn.cursor()
    
    SQL = 'SELECT * FROM mytable;' # insert your query here
    curs.execute(SQL)
    
    rows = curs.fetchall()
    
    curs.close()
    conn.close()
    
    # you could change the 'w' to 'a' for subsequent queries
    csv_writer = csv.writer(open('mytable.csv', 'w'), lineterminator='\n')
    
    for row in rows:
        csv_writer.writerow(row)
    

提交回复
热议问题