I am doing a data analysis with Python course and I am struggling to load the salika.db data base to perform some analysis. salika.db is saved in the same location as the notebook.
Image may be NSFW.
Clik here to view.
import numpy as npimport pandas as pdimport matplotlib.pyplot as plt import sqlite3 as sql%matplotlib inlineconn = sql.connect('sakila.db')df = pd.read_sql(''' SELECT rental.rental_id, rental.rental_date, rental.return_date, customer.last_name AS customer_lastname, store.store_id, city.city AS rental_store_city, film.title AS film_title, film.rental_duration AS film_rental_duration, film.rental_rate AS film_rental_rate, film.replacement_cost AS film_replacement_cost, film.rating AS film_rating FROM rental INNER JOIN customer ON rental.customer_id == customer.customer_id INNER JOIN inventory ON rental.inventory_id == inventory.inventory_id INNER JOIN store ON inventory.store_id == store.store_id INNER JOIN address ON store.address_id == address.address_id INNER JOIN city ON address.city_id == city.city_id INNER JOIN film ON inventory.film_id == film.film_id ;''', conn, index_col='rental_id', parse_dates=['rental_date', 'return_date'])
I get the following error message:
---------------------------------------------------------------------------OperationalError Traceback (most recent call last)File /opt/conda/envs/anaconda-panel-2023.05-py310/lib/python3.11/site-packages/pandas/io/sql.py:2202, in SQLiteDatabase.execute(self, sql, params) 2201 try:-> 2202 cur.execute(sql, *args) 2203 return curOperationalError: no such table: rentalThe above exception was the direct cause of the following exception:DatabaseError Traceback (most recent call last)Cell In[4], line 5 1 # Loading the data 3 conn = sql.connect('sakila.db')----> 5 df = pd.read_sql(''' 6 SELECT 7 rental.rental_id, rental.rental_date, rental.return_date, 8 customer.last_name AS customer_lastname, 9 store.store_id, 10 city.city AS rental_store_city, 11 film.title AS film_title, film.rental_duration AS film_rental_duration, 12 film.rental_rate AS film_rental_rate, film.replacement_cost AS film_replacement_cost, 13 film.rating AS film_rating 14 FROM rental 15 INNER JOIN customer ON rental.customer_id == customer.customer_id 16 INNER JOIN inventory ON rental.inventory_id == inventory.inventory_id 17 INNER JOIN store ON inventory.store_id == store.store_id 18 INNER JOIN address ON store.address_id == address.address_id 19 INNER JOIN city ON address.city_id == city.city_id 20 INNER JOIN film ON inventory.film_id == film.film_id 21 ; 22 ''', conn, index_col='rental_id', parse_dates=['rental_date', 'return_date'])File /opt/conda/envs/anaconda-panel-2023.05-py310/lib/python3.11/site-packages/pandas/io/sql.py:635, in read_sql(sql, con, index_col, coerce_float, params, parse_dates, columns, chunksize, dtype_backend, dtype) 633 with pandasSQL_builder(con) as pandas_sql: 634 if isinstance(pandas_sql, SQLiteDatabase):--> 635 return pandas_sql.read_query( 636 sql, 637 index_col=index_col, 638 params=params, 639 coerce_float=coerce_float, 640 parse_dates=parse_dates, 641 chunksize=chunksize, 642 dtype_backend=dtype_backend, # type: ignore[arg-type] 643 dtype=dtype, 644 ) 646 try: 647 _is_table_name = pandas_sql.has_table(sql)File /opt/conda/envs/anaconda-panel-2023.05-py310/lib/python3.11/site-packages/pandas/io/sql.py:2266, in SQLiteDatabase.read_query(self, sql, index_col, coerce_float, parse_dates, params, chunksize, dtype, dtype_backend) 2255 def read_query( 2256 self, 2257 sql, (...) 2264 dtype_backend: DtypeBackend | Literal["numpy"] = "numpy", 2265 ) -> DataFrame | Iterator[DataFrame]:-> 2266 cursor = self.execute(sql, params) 2267 columns = [col_desc[0] for col_desc in cursor.description] 2269 if chunksize is not None:File /opt/conda/envs/anaconda-panel-2023.05-py310/lib/python3.11/site-packages/pandas/io/sql.py:2214, in SQLiteDatabase.execute(self, sql, params) 2211 raise ex from inner_exc 2213 ex = DatabaseError(f"Execution failed on sql '{sql}': {exc}")-> 2214 raise ex from excDatabaseError: Execution failed on sql ' SELECT rental.rental_id, rental.rental_date, rental.return_date, customer.last_name AS customer_lastname, store.store_id, city.city AS rental_store_city, film.title AS film_title, film.rental_duration AS film_rental_duration, film.rental_rate AS film_rental_rate, film.replacement_cost AS film_replacement_cost, film.rating AS film_rating FROM rental INNER JOIN customer ON rental.customer_id == customer.customer_id INNER JOIN inventory ON rental.inventory_id == inventory.inventory_id INNER JOIN store ON inventory.store_id == store.store_id INNER JOIN address ON store.address_id == address.address_id INNER JOIN city ON address.city_id == city.city_id INNER JOIN film ON inventory.film_id == film.film_id ;': no such table: rental
I expected it create a dataframe from the data specified in my code.