cannot load index value from mysql database

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • tedpottel@gmail.com

    cannot load index value from mysql database

    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\c ustom-web-stats-
    project\web-stat.mdb")
    access = self.db.OpenRec ordset("select * from local_web_stat
    where 1")
    temp = self.db.OpenRec ordset("select * from lastid where 1")
    self.lastid=tem p.Fields("lasti d").Value

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

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

    access.Fields(" customer").valu e= 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_phras e"]
    access.Fields(" from_server").v alue = row["from_serve r"]
    access.Fields(" path_name").val ue = row["path_name"]
    id = row["PageID"]
    print id
    g=str(id)
    k=int(g)
    access.Fields(" PageID").value= k
    access.Fields(" server_name").v alue = row["server_nam e"]
    access.Fields(" file_name").val ue = row["file_name"]

    access.Update()
    temp.Edit()
    temp.Fields("la stid").Value=k
    temp.Update()
Working...