There are few problems:
- The SQL should be provided in quotes because the execute() method accepts a
string argument.
index
is a reserved keyword in SQL, so you cannot use
that as the name of your column.
- If you want to run this script
repeatedly, you should add
IF NOT EXISTS
clause. Otherwise
consequent runs will fail due to "table already exists"
So, after these changes the statement looks like below:
c.execute("CREATE table IF NOT EXISTS Movies(myindex integer, mvnm text, year integer, genere text)")
You can then verify the table creation by logging in to sqllite:
$> ~ $ sqlite3 example.db
SQLite version 3.8.10.2 2015-05-20 18:17:19
Enter ".help" for usage hints.
sqlite> .tables
Movies