Storing a two dimensional list structure with different item types in Postgres 9.1

19 views
Skip to first unread message

Andreas Jung

unread,
Dec 20, 2012, 5:20:57 AM12/20/12
to sqlal...@googlegroups.com
Using Postgres 9.1, SqlAlchemy 0.8.

I need to store information like

[
[10, 'liters', 'tea'],
[20, 'milliliters', 'salt'],
]

as one column into Postgres.

What is the best way to do this? Of course I use a second table with a 1:N relationship....
I am thinking about using the Postgres Array type for this...is there a better option?
Right now there are numeric and string values to be stored. I can of course
convert numeric values to strings if needed.

Any options?

Andreas

Robert Forkel

unread,
Dec 20, 2012, 5:25:59 AM12/20/12
to sqlal...@googlegroups.com
If you are only after storage (leaving aside querying, indexing, ...)
a simple JSON column [1] could do. The advantage being portability
between databases. I've used this to as simple key-value store of data
associated with a row.
regards
robert

[1] http://docs.sqlalchemy.org/en/rel_0_8/core/types.html#marshal-json-strings
> --
> You received this message because you are subscribed to the Google Groups
> "sqlalchemy" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/sqlalchemy/-/9jnn5iZY68IJ.
> To post to this group, send email to sqlal...@googlegroups.com.
> To unsubscribe from this group, send email to
> sqlalchemy+...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/sqlalchemy?hl=en.
Reply all
Reply to author
Forward
0 new messages