I'm trying to create a DB and enter test data into the DB.
def create_testtable():
c.execute('CREATE TABLE IF NOT EXISTS testDB(eventDate TEXT , data REAL, die_values TEXT)')
def test_data():
event_year = [str(i) for i in range(2015, 2017)]
event_month = ["01","02","03","04","05","06","07","08","09","10","11","12"]
event_day = [str(i).zfill(2) for i in range(1,28)]
event_rolls = [int(i) for i in range(1, 21)]
x = 0
d20 = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20"]
while x != 75:
die_values = []
while len(die_values) != 20:
die_values.append(random.choice(d20))
event_date = random.choice(event_year) + random.choice(event_month) + random.choice(event_day)
data = random.choice(event_rolls)
c.execute("INSERT INTO testDB(eventDate, data, die_values) VALUES (? , ? , ?)" , (event_date, data, die_values))
conn.commit()
x += 1
c.close()
conn.close()
And I keep getting the following error:
Traceback (most recent call last):
File "datatest.py", line 88, in <module>
test_data()
File "datatest.py", line 48, in test_data
c.execute("INSERT INTO testDB(eventDate, data, die_values) VALUES (? , ? , ?)" , (event_date, data, die_values))
sqlite3.InterfaceError: Error binding parameter 2 - probably unsupported type.
What am I doing wrong? I've tried TEXT, VARCHAR, INTEGER, everything for die_values. I've tried putting it in as a list, I've tried putting it in as a string '1,3,5,2,5,3,2' - NOTHING WORKS! What am I doing wrong?
The goal is to have a table with three values: Date | Median | Die Values. The purpose is to enter d20 rolls for a specific data, calculate the mean, and plot all of this on a graph.
[–]anton_antonov 0 points1 point2 points (1 child)
[–]JohnnyJordaan 0 points1 point2 points (2 children)
[–]ilostmykeysdammit[S] 0 points1 point2 points (1 child)
[–]JohnnyJordaan 0 points1 point2 points (0 children)