I need to pass a python dict to a database with SQL.
one of my dicts is:
print(student[1])
{'first': 'Adrian', 'house': 'Slytherin', 'birth': '1977', 'middle': 'NULL', 'last': 'Pucey'}
I want to fill the database with this code:
db = SQL("sqlite:///students.db") #grant acces to data base in SQL
db.executemany("""
INSERT INTO
students
(first, house, birth, middle, last)
VALUES
(%(first)s, %(house)s, %(birth)s, %(middle)s, %(last)s)
""", student[1])
The return I got is: AttributeError: 'SQL' object has no attribute 'executemany'
What I've done wrong?
What to do in order to inject a python dict with SQL?
Thanks in advance,