I have some difficulties to come up with proper title for my problem.
I’m trying to learn a little bit about SQLite and database and I came up with little exercise (I’m aware that for this specific case making multiple tables doesn’t make much sense, it’s all just for exercise and finding out ‘how-to’). The database is supposed to contain a few tables: main “movies table”, “year table”, “director table” and “category table”. Picture for easier understanding.
After creating tables, I wanted to populate them with tuple of tuples. I have no problem with “little” tables for example, populating directors table.
Dir = ((0, ‘Blip’), (1, ‘Blop’), (2, ‘Blap’))
then:
with con:
cur = con.cursor()
cur.execute("DROP TABLE IF EXISTS Directors")
cur.execute("CREATE TABLE Directors(Id INT PRIMARY KEY, Director TEXT)")
cur.executemany("INSERT INTO Directors VALUES(?, ?, ?)", Dir)
The problem appears with main movie table. How to pass multitude category values for each movie? Should I pass this collection of values as another tuple?
Movies = ((‘Dog’, 0, 0, 1), (‘Cat’, 0, 0, (1, 2)),
(‘Ant’, 1, 1, (0, 2)), (‘Crow’, 2, 2, (0, 1, 2)))