#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2014
    Posts
    1
    Rep Power
    0

    [PYTHON] MySQL insert into ...


    So i have some code and how i can add into it mysql insert ?
    class Master(object):
    def log(self, infohash, address=None):
    stdger.debug("%s|%s:%s" % (infohash.encode("hex"), address[0], address[1]))
    fileger.debug('%s|%s:%s' % (infohash.encode('hex').upper(),address[0],address[1]))
    //here i need have mysql code to insert infohash.encode("hex") and address[0]
    if __name__ == "__main__":
    #max_node_qsize bigger, bandwith bigger, spped higher
    initialLog()
    threads = []
  2. #2
  3. Contributing User

    Join Date
    Aug 2011
    Posts
    5,141
    Rep Power
    482
    I'm aware of two choices. Your python code can write a mysql script that inserts the data, then run mysql as a separate task. That's how I'd solve the problem. The other choice: connect directly to mysql using the programmatic interface. There you'd logon, open the table making a "cursor", then you'd issue the insert into command using some method available to the cursor.
    [code]Code tags[/code] are essential for python code and Makefiles!

IMN logo majestic logo threadwatch logo seochat tools logo