Python, Sqlite3 - How to convert a list to a BLOB cell

前端 未结 5 896
梦谈多话
梦谈多话 2020-12-06 02:55

What is the most elegant method for dumping a list in python into an sqlite3 DB as binary data (i.e., a BLOB cell)?

data = [ 0, 1, 2, 3, 4, 5 ]
# now write t         


        
5条回答
  •  北荒
    北荒 (楼主)
    2020-12-06 03:21

    See this general solution at SourceForge which covers any arbitrary Python object (including list, tuple, dictionary, etc):

    y_serial.py module :: warehouse Python objects with SQLite

    "Serialization + persistance :: in a few lines of code, compress and annotate Python objects into SQLite; then later retrieve them chronologically by keywords without any SQL. Most useful "standard" module for a database to store schema-less data."

    http://yserial.sourceforge.net

提交回复
热议问题