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

2012-12-20 Thread Andreas Jung
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

Re: [sqlalchemy] Storing a two dimensional list structure with different item types in Postgres 9.1

2012-12-20 Thread Robert Forkel
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]

[sqlalchemy] Re: exception message encoded in utf8

2012-12-20 Thread Sylvain Prat
Sorry to ressurrect this thread but the problem is still there. Since SQLAlchemy knows the encoding used to communicate with the database, it can properly decode the error strings returned by the database to unicode. So, I think it should be SQLAlchemy's responsibility to convert the error

Re: [sqlalchemy] Re: exception message encoded in utf8

2012-12-20 Thread Michael Bayer
OK as I said earlier, I'm not able to reproduce this.So I'd need that reproduction case in order to do anything. To be honest it sounds more like a psycopg2 bug, since psycopg2 does the decoding in most cases nowadays and even works with Python 3, so for it to be raising an exception with

[sqlalchemy] How to SELECT FOR SHARE in PostgreSQL dialect?

2012-12-20 Thread utkonos
I am trying SELECT FOR SHARE a set of rows in a table so that they are locked until the end of the transaction. I am using SQLAlchemy 0.7.9 to do this in a PostgreSQL 9.1.6 database. This is the python code in question: NUM_TERMS = 10 conn = engine.connect() get_terms =

Re: [sqlalchemy] How to SELECT FOR SHARE in PostgreSQL dialect?

2012-12-20 Thread Michael Bayer
can't reproduce: from sqlalchemy import * m = MetaData() t = Table('t', m, Column('x', Integer)) s = select([t], for_update=read) from sqlalchemy.dialects import postgresql print s.compile(dialect=postgresql.dialect()) e = create_engine(postgresql://scott:tiger@localhost/test, echo=True) with

Re: [sqlalchemy] How to SELECT FOR SHARE in PostgreSQL dialect?

2012-12-20 Thread Michael Bayer
The problem is the SQL query generated by the select code above is not FOR SHARE, it's FOR UPDATE: SELECT search_terms.term_id, search_terms.term FROM search_terms WHERE search_terms.lock = :lock_1 AND search_terms.status = :status_1 ORDER BY search_terms.term LIMIT :param_1 FOR