I currently have a txt file of movies which contain a movieID,Movie Name, and genre. Example:
1,Toy Story (1995),Animation|Children's|Comedy
2,Jumanji (1995),Adventure|Children's|Fantasy
3,Grumpier Old Men (1995),Comedy|Romance
4,Waiting to Exhale (1995),Comedy|Drama
5,Father of the Bride Part II (1995),Comedy
I am trying to import this file into a SQLite3 table created with Python:
import sqlite3
conn = sqlite3.connect('CSC 452 Final.db')
c=conn.cursor()
Drop Tables
c.execute('''DROP TABLE IF EXISTS temp_movie''')
print("Table temp_movie dropped.")
Create Table for Movies
c.execute('''CREATE TABLE temp_movie (
MovieID NUMERIC (5),
movie_title_year VARCHAR2 (255),
movie_categories VARCHAR2 (255),
CONSTRAINT movies_movieID_PK PRIMARY KEY (
MovieID
))''')
print("Table temp_movie successfully created.")
conn.commit()
What's the best way to import my text file into this database with the delimiter being ','?