No such column id - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: No such column id (/thread-24640.html) |
No such column id - Linuxdesire - Feb-24-2020 I found a tutorial where you can input a movie in the terminal and it prints out on screen. It gets the information from IMDB. That part works fine. But then I decided I wanted to import that information to a SQLite database. When I run my program the table is made but it will not populate due to errors. One error is "no such column: id, so I deleted that just to see what would happen. It just goes to the next one and say "no such column: title. Here is the code to print to screen that works: import imdb import sqlite3 hr=imdb.IMDb() movie_name=input("Enter the movie name : ") movies=hr.search_movie(str(movie_name)) index=movies[0].getID() movie=hr.get_movie(index) title=movie['title'] year=movie['year'] cast=movie['cast'] rating=movie['rating'] plot=movie['plot'] list_of_cast=',' .join(map(str,cast)) print("title",title) print("year of release: ",year) print("full cast : ",list_of_cast) print("rating: ",rating) print("plot: ",plot) print(movie.asXML())I added the following for the SQLite database: import sqlite3 from sqlite3 import Error conn = sqlite3.connect('movies.db') c = conn.cursor() print ("Opened database successfully"); conn.execute('''CREATE TABLE IF NOT EXISTS data (ID INT PRIMARY KEY NOT NULL, title TEXT NOT NULL, year_of_release INT NOT NULL, full_cast TEXT NOT NULL, plot TEXT);''') print("Table created successfully"); conn.execute("INSERT INTO data (id, title, year_of_release, full_cast, plot) \ VALUES (id, title, year_of_release, full_cast, plot)"); conn.commit() print("Records created successfully"); conn.close() conn.close()This is the traceback: Thank you for any help that can be provided.
RE: No such column id - jefsummers - Feb-24-2020 You get index from IMDB, but then try to post id. From what I see, you do not assign a value to id. I have not worked with SQLite, but since your values are all within the quotation marks, how will SQLite get access to the actual variables? |