import sqlite3
import pandas as pd
slice3_path=r"F:\GM RWA\Database\Wild.sql"
conn = sqlite3.connect(slice3_path)
sql='''SELECT DOG, CAT, TIGER
FROM
(SELECT *
FROM "Mammals")
GROUP BY DOG, CAT, TIGER
ORDER BY TIGER asc'''
df = pd.read_sql(sql=sql, con=conn)
print(df)
This is the code I have written to try to import an existing query I've written in DB Browser for SQ Lite into python. However, I received an error message that says, sqlite3.OperationalError: disk I/0 Error and claiming there was a pandas.io.sql.Databased Error, and the Execution failed on sql. Any idea why this is happening?
You need to surround your string with quotes:
slice3_path = r"F:\GM RWA\Database\Wild.sql"
The r in front of the string tells Python to treat the backslashes as just backslashes.