--
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/-/xgqjb8tLAW8J.
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.
this is an issue of two edge cases.One edge case is you want to emit this SQL on SQLite:select query_users.user_id, query_users.user_name from query_usersUNION select query_users.user_id, query_users.user_name from query_usersand then access the columns like this:row["user_id"], row["user_name"]which is of course how every other database does it. Only SQLite decides that only when a UNION is present, it's going to prepend the tablename to the keys in cursor.description. So we strip them off so that the ORM and everything else still works when a query like this comes through.
The other edge case is you want to explicitly use a label with a dot in it.
As it stands, we can choose among these two edge cases, and I'd note in the current behavior, you *can* access your column using "foo.bar", it's just not in keys() that way. In my view, being able to emit a UNION with table-qualified columns is a lot more common than labels with dots in them. Why not use another character that isn't meaningful in SQL ?
On Apr 27, 2012, at 2:24 AM, Stefan Urbanek wrote:
Hi,I had this problem ~year ago (see [1]). Now with SQLAlchemy 0.7.6 I am having this same problem back again. Here is a piece of code that shows this behaviour, in comparison to other backends as well:Verbosity and non-reusing instances is intentional.Is there any workaround for this issue?Thanks for any hints,Stefan[1] http://bit.ly/Je8V4I Selecting columns with dots in their names--
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/-/xgqjb8tLAW8J.
To post to this group, send email to sqlal...@googlegroups.com.
To unsubscribe from this group, send email to sqlalchemy+unsubscribe@googlegroups.com.
This is what I used as workaround [1]:# select is sqlalchemy.sql.expression.select()# each selected column was derived as column = table.c[reference].label(label_with_dot)labels = [c.name for c in select.columns]...record = dict(zip(labels, row))
--
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
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.
On 28.4.2012, at 18:39, Michael Bayer wrote:On Apr 28, 2012, at 5:52 AM, Stefan Urbanek wrote:This is what I used as workaround [1]:# select is sqlalchemy.sql.expression.select()# each selected column was derived as column = table.c[reference].label(label_with_dot)labels = [c.name for c in select.columns]...record = dict(zip(labels, row))please try out the patch at http://www.sqlalchemy.org/trac/attachment/ticket/2475/2475.patch . This would provide:conn = engine.connect().execution_options({"sqlite_raw_colnames":True})result = conn.execute(stmt)no removal of dots would proceed.if this works for you it can go right in to 0.7 and 0.8.Thanks, works nicely. (had to change to: execution_options(sqlite_raw_colnames=True)).Is there (going to be) a way how I would be able to pass this option to the engine, so I can have all connections like that?