I have an sql file locally stored in my PC. I want to open and read it using the pandas library. Here it iswhat I have tried:
import pandas as pd
import sqlite3
my_file = 'C:\Users\me\Downloads\\database.sql'
#I am creating an empty database
conn = sqlite3.connect(r'C:\Users\test\Downloads\test.db')
#I am reading my file
df = pd.read_sql(my_file, conn)
However, I am receiving the following error:
DatabaseError: Execution failed on sql 'C:\Users\me\Downloads\database.sql': near "C": syntax error
my_file = r'C:\Users\me\Downloads\\database.sql'so you pass a raw string, or use forward slashesmy_file = 'C://Users/me/Downloads/database.sql''\U'in'C:\Users'to unicode which will break the "path string". Definitely userto signify it's a raw string. Also see: en.wikipedia.org/wiki/…