Я пытаюсь импортировать мои данные (.sql) и преобразовать их в .csv в моем коде Python.Я решил использовать sqlite3 для подключения data.sql, но я нахожу эту ошибку:
(оставляю код и ошибку ниже)
import sqlite3
# Open the file
f = open('output.csv', 'w')
# Create a connection and get a cursor
connection = sqlite3.connect('data.sql')
cursor = connection.cursor()
# Execute the query
cursor.execute('select * from data')
# Get data in batches
while True:
# Read the data
df = pd.DataFrame(cursor.fetchmany(1000))
# We are done if there are no data
if len(df) == 0:
break
# Let's write to the file
else:
df.to_csv(f, header=False)
# Clean up
f.close()
cursor.close()
connection.close()
cursor.execute('select * from data')
sqlite3.DatabaseError: file is not a database