The best way to store a python list to a database?

前端 未结 4 1384
一生所求
一生所求 2021-02-06 11:50

What would be the best way of storing a python list of numbers (such as [4, 7, 10, 39, 91]) to a database? I am using the Pyramid framework with SQLAlchemy to communicate to a d

4条回答
  •  广开言路
    2021-02-06 12:13

    Well conceptually you can store a list as a bunch of rows in a table using a one-to-many relation, or you can focus on how to store a list in a particular database backend. For example postgres can store an array in a particular cell using the sqlalchemy.dialects.postgres.ARRAY data type which can serialize a python array into a postgres array column.

提交回复
热议问题