I have webscraped data into a pickle file and want to write that data into a sqlite3 database. Can anybody help me out with what needs to be done?
You need to create a column of type BLOB
(which is a supported datatype in Sqlite3).
Then, you can just INSERT INTO data (id, content) VALUES (?, ?)
with the binary dump of your pickle object.
Here's a walk through on Sqlite3 inserts .
pickle.dumps
will convert the object into a byte-string you can store in the database. pickle.loads
will turn it back after being SELECT
'd from the database.
You can also consider using dill
for more complex objects.
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.