cannot load index value from mysql database

T

tedpottel

Hi

I am trying to right a script to keep a local copy of my mysql
database in a local access file. I was able to do this in Access
visual basic, but cannot get it to work in python.

The procedure works by storing the last index value after each
update. Then I do a quarry for all records with a index value bigger
the the last one stored.

In python when I try to get the index value, ID it gives me a
keyword. I know the firled exist because I am doing the following
querry


Here is the code,
Help!!!!!!

engine = win32com.client.Dispatch("DAO.DBEngine.36")
self.db=engine.OpenDatabase(r"w:\consulting\custom-web-stats-
project\web-stat.mdb")
access = self.db.OpenRecordset("select * from local_web_stat
where 1")
temp = self.db.OpenRecordset("select * from lastid where 1")
self.lastid=temp.Fields("lastid").Value

#open mysql
conn = MySQLdb.connect ("……….")
cursor = conn.cursor (MySQLdb.cursors.DictCursor)
cursor.execute ("SELECT * FROM web_stat where
ID>"+str(self.lastid))
result_set = cursor.fetchall ()

for row in result_set:
last=row["ID"]b (this does not work why???????)
access.Edit()

access.Fields("customer").value= row["customer"]
t=row["time"]
print t

access.Fields("Time").value=t
access.Fields("phrase").value= row["phrase"]
access.Fields("key_word_phrase").value =
row["key_word_phrase"]
access.Fields("from_server").value = row["from_server"]
access.Fields("path_name").value = row["path_name"]
id = row["PageID"]
print id
g=str(id)
k=int(g)
access.Fields("PageID").value=k
access.Fields("server_name").value = row["server_name"]
access.Fields("file_name").value = row["file_name"]

access.Update()
temp.Edit()
temp.Fields("lastid").Value=k
temp.Update()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,059
Latest member
cryptoseoagencies

Latest Threads

Top