python导入数据到access,使用pyodbc从Python应用程序将值插入到Access 2003数据库

I've checked stackoverflow a lot in the past and have always been able to find what I've been looking for, but I just can't seem to get this one to work so I'm asking my first question.

I'm not really a programmer, but I mentioned Python at work and now I have a Python project. I was actually getting everything figured out alright, but inserting values into a database is throwing me for a loop.

The Basic Problem:

I have a form built using Python and tkinter. When a button on the form is pressed I want values to be inserted into a database.

The Details:

I'm working with Python 3.4, pyodbc, and an Access 2003 database.

The database is just 1 table called file_info and it has the following fields, the fields data type is listed behind the pipe.

ID | AutoNumber

filename | Text

date | Date/Time

batch_amount | Number

parcel_amount | Number

sum_amount | Number

Eventually I'd like to insert some values calculated in other functions, but currently I'm just trying to insert some set values via a function and I can't get it to work.

Connection string:

db_file = r'''C:\Users\amarquart\Documents\testlockboxdb.mdb'''

user = 'admin'

password = ''

odbc_conn_str = 'DRIVER={Microsoft Access Driver (*.mdb,

*.accdb)};DBQ=%s;UID=%s;PWD=%s' % \

(db_file, user, password)

conn = pyodbc.connect(odbc_conn_s

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值