1
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?

1 Answer 1

0

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Gotcha thanks, that fixed a lot of it, I edited my question because there's another weird error, but thank you that was helpful!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.