from win32com.client import Dispatch as CreateObject
conn = CreateObject("ADODB.Connection")
mdb = r"C:\northwind.mdb"
conn.Open("Driver={Microsoft Access Driver (*.mdb)}; DBQ=%s;"%mdb)
def execRequest(sql):
r,t = conn.Execute(sql )
cust = "<table>\n"
while not r.EOF:
s = "<tr>"
for item in r.Fields:
if item.Name == "ContactName" or item.Name == "Address":
s+= "<td>%s</td>"%(item.Value)
s += "</tr>\n"
cust += s
r.MoveNext()
cust += "</table>\n"
return cust
cust = execRequest("select * from customers")
conn.Close()
Sunday, March 2, 2008
ADO - Python
Querying ACCESS with Python
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment