简体   繁体   中英

Disk I/O Error when importing from SQL into python

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM