lundi 25 avril 2016

Trying to insert value from txt file with sqlite in python

def quantity():
    i = 0
    x = 1

    file = open("john.txt", "r")

    while i < 5000:

        for line in file:
            c.execute("INSERT INTO test (playerNAME, playerID) VALUES ("+line+", "+str(x)+")")
            conn.commit()

            x = random.randint(100,10000000000000000)
            i += 1

I try to iterate through the John.txt file and insert each value into a table. The first word in the txt file is "abc123". When I run this code there is an error: sqlite3.OperationalError: no such column: abc123

I can get the code to enter the random numbers into playerID but I can't get the txt file query to work...

Aucun commentaire:

Enregistrer un commentaire