Connection error to Access database

前端 未结 3 728
醉梦人生
醉梦人生 2021-01-21 15:39

I wrote the program which by means of pyodbc is connected to Access to that it was very glad. Help me please.

import pyodbc
#import kinterbasdb
import firebirdsq         


        
3条回答
  •  面向向阳花
    2021-01-21 15:57

    This might help.

    import pyodbc
    
    # Connect to your access database file
    
    DBfile = 'Filename.mdb'  # Let your file name  and access extension .mdb
    conn = pyodbc.connect('DRIVER={Microsoft Access Driver (*.mdb)};DBQ='+DBfile)  #    user/password can be used
    cur = conn.cursor()
    
    # Create new table in database
    
    cur.execute ('CREATE TABLE CLIENTS (ID INTEGER, COMPANY STRING)')
    conn.commit()
    
    cur.close()
    conn.close()
    

提交回复
热议问题