database - INSERT python list into MySQL DB -
i got code not getting working
listdata = [1, 2] listdata1.insert(1, raw_input("enter first thing db: ") listdata2.insert(2, raw_input("enter second thing db: ")
then make db, then
cursor.execute("insert testdb (table, table) values (%s, %s)", (listdata1, listdata2
which gives me: nameerror: name 'listdata1' not defined
is inserting possible way? or how work?
the problem happens here:
listdata1.insert(1, raw_input("enter first thing db: ")
you did not define variable listdata1
yet. change listdata , fix nameerror.
besides, can append instead of insert e.g.
listdata.append( raw_input("enter first thing db: ") )
then raw input kept in position 0 in listdata, , can retrieve listdata[0]
the sql looks wrong ('table' appear twice)
Comments
Post a Comment