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?

throway172
  • 123
  • 2
  • 4
  • 12

1 Answers1

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.

spejsy
  • 123
  • 8
  • Gotcha thanks, that fixed a lot of it, I edited my question because there's another weird error, but thank you that was helpful! – throway172 Jul 02 '18 at 13:28