24👍
✅
sql = f.read() # watch out for built-in `str`
cur.executescript(sql)
4👍
Try using
con.executescript(str)
Documentation
Connection.executescript(sql_script)
This is a nonstandard shortcut that creates an intermediate cursor object
by calling the cursor method, then calls the cursor’s executescript
method with the parameters given.
Or create the cursor first
import sqlite3
con = sqlite3.connect('../sqlite.db')
f = open('../dump.sql','r')
str = f.read()
cur = con.cursor()
cur.execute(str)
- How to display "x days ago" type time using Humanize in Django template?
- How to run a Django celery task every 6am and 6pm daily?
Source:stackexchange.com