I got a tuple whose elements are int or real numbers and I need to create a sqlite3 table assigning to each column name the correspondent element into the tuple.
Here’s my code:
fAEHz=('20','25','31.5','40','50','63')
conn = sqlite3.connect('daticert.db')
cur = conn.cursor()
columns = " TEXT, ".join([str(freq) for freq in fAEHz])
command = "CREATE TABLE IF NOT EXISTS mk221ae (" + columns + " TEXT)"
cur.execute(command)
conn.commit()
There’s something wrong since I got the following message:
", line 293, in <module>
cur.execute(command)
sqlite3.OperationalError: near "20": syntax error
If I use a tuple whose elements are strings (as shown below), everything works fine!
fAEHz = ["Name", "Address", "Email", "Phone"]
Is there any solution or it is forbidden to give sqlite3 column name a number?
Thank you ever so much.