Python help for Access database

shakir iamshakir at gmail.com
Mon Jul 31 15:09:19 EDT 2006


HI All,

I need help for inserting recods into the access database using python
script through ODBC. I can insert data without any problem if I hard
coded the run_Date field. But I need run_Date field should be mytime..
I am getting error Data type mismatch in criteria expression. in EXEC

I really appreciate if anyone can help me.

Thanks in advance

Shakir

# mdbupdate.py

import sys
import os
import os.path
import shutil
import time
import sys, string, os, win32com.client
import odbc


mytime = time.strftime('%m/%d/%Y')
mytimeYMD = time.strftime('%Y%m%d')
conn = odbc.odbc("test1_Data")
cursor = conn.cursor()



# data type in mdb is as follows: application -> Text, Run_Date ->
Date, Run_dateYMD -> #number, status -> Script



cursor.execute("INSERT INTO local_cmgenadm (Application,Run_Date,
Run_DateYMD,status) values (\'MyApp1\',\'%s\', \'20060731\' ,
\'Good\')")%mytime



cursor.close()
                           
conn.close()




More information about the Python-list mailing list