python 连接数据库 (Access)

模块pypyodbc 1.3.3下载:   https://pypi.python.org/pypi/pypyodbc/

安装:解压文件找到pypyodbc.py复制到python安装目录Lib文件夹下即可

import pypyodbc 

             

pypyodbc.win_create_mdb('D:\\database.mdb')



connection_string = 'Driver={Microsoft Access Driver (*.mdb)};DBQ=D:\\database.mdb'



connection = pypyodbc.connect(connection_string)



SQL = 'CREATE TABLE saleout (id COUNTER PRIMARY KEY,product_name VARCHAR(25));'



connection.cursor().execute(SQL).commit()

http://www.next-second.com/s/pypyodbc_tutorial_en.htm

你可能感兴趣的:(python)