[sqlalchemy] Error querying stored values
Hello, I am using SQLAlchemy 0.9.3, cx_oracle 5.1.2 with an Oracle database 11.2.0.3.0 that has a table called ticket_log which saves the state of a ticket and has an autoincremental id, user, date, hour, ticket number and an observation column which is always empty by default and can only be edited by hand, for example, with SQLDeveloper. When I was testing adding a value to the observation column, whenever I tried to query the table I would get this error: *'str' object has no attribute 'read' * And this is the traceback: *Traceback (most recent call last): File ***/server.py, line 288, in _dispatchresultado = funcion(parametros) File ***/ticket_log.py, line 64, in obtener_log_x_ticketfuncion) File ***/utils.py, line 69, in wrapperresult = f(*args) File ***/ticket_log.py, line 185, in get_log_por_nro_de_tickett_log.id_ticket_log).all() File ***/.virtualenvs/tickets/local/lib/python2.7/site-packages/sqlalchemy/orm/query.py, line 2286, in allreturn list(self) File ***/.virtualenvs/tickets/local/lib/python2.7/site-packages/sqlalchemy/orm/loading.py, line 75, in instanceslabels) for row in fetch] File ***/.virtualenvs/tickets/local/lib/python2.7/site-packages/sqlalchemy/orm/query.py, line 3457, in procreturn row[column] File ***/.virtualenvs/tickets/local/lib/python2.7/site-packages/sqlalchemy/dialects/oracle/cx_oracle.py, line 307, in processreturn value.read()AttributeError: 'str' object has no attribute 'read''str' object has no attribute 'read'* And this is the query: *with db.session as session:with qmodify(session.query(t_log.id_movimiento, t_log.id_usuario, t_log.fecha,t_log.hora, t_log.estado_ticket, t_log.observaciones, tickets.nro_ticket), with_context=self) as qom: t_logs_x_nro_ticket = qom.filter_by()\ .filter_.by_productora( field=t_log.id_productora)\ .join( tickets, tickets.id_movimiento==t_log.id_movimiento, ).join( funciones, funciones.id_funcion==func.substr(t_log.id_localidad,0,9) )# Filtra por un ticketif (nro_ticket is not None and nro_ticket != ''):# O de un ticket a otroif (nro_ticket_hasta is not None and nro_ticket_hasta != ''):t_logs_x_nro_ticket = t_logs_x_nro_ticket.filter( tickets.nro_ticket = nro_ticket, tickets.nro_ticket = nro_ticket_hasta) else:t_logs_x_nro_ticket = t_logs_x_nro_ticket.filter( tickets.nro_ticket == nro_ticket)if (len(funcion) == 9):t_logs_x_nro_ticket = t_logs_x_nro_ticket.filter( func.substr(t_log.id_localidad,0,9) == funcion) else:t_logs_x_nro_ticket = t_logs_x_nro_ticket.filter( funciones.id_espectaculo == funcion)# O sino por todos los tickets de una función, entonces# Lo ordeno y ya le pido que me pase todos los resultadost_logs_x_nro_ticket = t_logs_x_nro_ticket.order_by( tickets.nro_ticket, t_log.id_ticket_log).all()* Is there any reason why I can't add or modify values from the database without getting this error? -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
Re: [sqlalchemy] Error querying stored values
On Tue, Apr 29, 2014 at 2:42 PM, Leandro Poblet lpob...@msa.com.ar wrote: Hello, I am using SQLAlchemy 0.9.3, cx_oracle 5.1.2 with an Oracle database 11.2.0.3.0 that has a table called ticket_log which saves the state of a ticket and has an autoincremental id, user, date, hour, ticket number and an observation column which is always empty by default and can only be edited by hand, for example, with SQLDeveloper. When I was testing adding a value to the observation column, whenever I tried to query the table I would get this error: 'str' object has no attribute 'read' And this is the traceback: Traceback (most recent call last): File ***/server.py, line 288, in _dispatch resultado = funcion(parametros) File ***/ticket_log.py, line 64, in obtener_log_x_ticket funcion) File ***/utils.py, line 69, in wrapper result = f(*args) File ***/ticket_log.py, line 185, in get_log_por_nro_de_ticket t_log.id_ticket_log).all() File ***/.virtualenvs/tickets/local/lib/python2.7/site-packages/sqlalchemy/orm/query.py, line 2286, in all return list(self) File ***/.virtualenvs/tickets/local/lib/python2.7/site-packages/sqlalchemy/orm/loading.py, line 75, in instances labels) for row in fetch] File ***/.virtualenvs/tickets/local/lib/python2.7/site-packages/sqlalchemy/orm/query.py, line 3457, in proc return row[column] File ***/.virtualenvs/tickets/local/lib/python2.7/site-packages/sqlalchemy/dialects/oracle/cx_oracle.py, line 307, in process return value.read() AttributeError: 'str' object has no attribute 'read' 'str' object has no attribute 'read' And this is the query: with db.session as session: with qmodify(session.query( t_log.id_movimiento, t_log.id_usuario, t_log.fecha, t_log.hora, t_log.estado_ticket, t_log.observaciones, tickets.nro_ticket), with_context=self) as qom: t_logs_x_nro_ticket = qom.filter_by()\ .filter_.by_productora( field=t_log.id_productora)\ .join( tickets, tickets.id_movimiento==t_log.id_movimiento, ).join( funciones, funciones.id_funcion==func.substr(t_log.id_localidad,0,9) ) # Filtra por un ticket if (nro_ticket is not None and nro_ticket != ''): # O de un ticket a otro if (nro_ticket_hasta is not None and nro_ticket_hasta != ''): t_logs_x_nro_ticket = t_logs_x_nro_ticket.filter( tickets.nro_ticket = nro_ticket, tickets.nro_ticket = nro_ticket_hasta) else: t_logs_x_nro_ticket = t_logs_x_nro_ticket.filter( tickets.nro_ticket == nro_ticket) if (len(funcion) == 9): t_logs_x_nro_ticket = t_logs_x_nro_ticket.filter( func.substr(t_log.id_localidad,0,9) == funcion) else: t_logs_x_nro_ticket = t_logs_x_nro_ticket.filter( funciones.id_espectaculo == funcion) # O sino por todos los tickets de una función, entonces # Lo ordeno y ya le pido que me pase todos los resultados t_logs_x_nro_ticket = t_logs_x_nro_ticket.order_by( tickets.nro_ticket, t_log.id_ticket_log).all() Is there any reason why I can't add or modify values from the database without getting this error? I've never used oracle with sqlalchemy before, but looking at the bottom of the stack trace, is it possible that you have declared your column as some sort of BLOB type but it is actually a simpler data type in the database? Hope that helps, Simon -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
Re: [sqlalchemy] Error querying stored values
That was the problem. I had it declared as a Text() instead of String(). Thanks! El martes, 29 de abril de 2014 11:49:12 UTC-3, Simon King escribió: On Tue, Apr 29, 2014 at 2:42 PM, Leandro Poblet lpo...@msa.com.arjavascript: wrote: Hello, I am using SQLAlchemy 0.9.3, cx_oracle 5.1.2 with an Oracle database 11.2.0.3.0 that has a table called ticket_log which saves the state of a ticket and has an autoincremental id, user, date, hour, ticket number and an observation column which is always empty by default and can only be edited by hand, for example, with SQLDeveloper. When I was testing adding a value to the observation column, whenever I tried to query the table I would get this error: 'str' object has no attribute 'read' And this is the traceback: Traceback (most recent call last): File ***/server.py, line 288, in _dispatch resultado = funcion(parametros) File ***/ticket_log.py, line 64, in obtener_log_x_ticket funcion) File ***/utils.py, line 69, in wrapper result = f(*args) File ***/ticket_log.py, line 185, in get_log_por_nro_de_ticket t_log.id_ticket_log).all() File ***/.virtualenvs/tickets/local/lib/python2.7/site-packages/sqlalchemy/orm/query.py, line 2286, in all return list(self) File ***/.virtualenvs/tickets/local/lib/python2.7/site-packages/sqlalchemy/orm/loading.py, line 75, in instances labels) for row in fetch] File ***/.virtualenvs/tickets/local/lib/python2.7/site-packages/sqlalchemy/orm/query.py, line 3457, in proc return row[column] File ***/.virtualenvs/tickets/local/lib/python2.7/site-packages/sqlalchemy/dialects/oracle/cx_oracle.py, line 307, in process return value.read() AttributeError: 'str' object has no attribute 'read' 'str' object has no attribute 'read' And this is the query: with db.session as session: with qmodify(session.query( t_log.id_movimiento, t_log.id_usuario, t_log.fecha, t_log.hora, t_log.estado_ticket, t_log.observaciones, tickets.nro_ticket), with_context=self) as qom: t_logs_x_nro_ticket = qom.filter_by()\ .filter_.by_productora( field=t_log.id_productora)\ .join( tickets, tickets.id_movimiento==t_log.id_movimiento, ).join( funciones, funciones.id_funcion==func.substr(t_log.id_localidad,0,9) ) # Filtra por un ticket if (nro_ticket is not None and nro_ticket != ''): # O de un ticket a otro if (nro_ticket_hasta is not None and nro_ticket_hasta != ''): t_logs_x_nro_ticket = t_logs_x_nro_ticket.filter( tickets.nro_ticket = nro_ticket, tickets.nro_ticket = nro_ticket_hasta) else: t_logs_x_nro_ticket = t_logs_x_nro_ticket.filter( tickets.nro_ticket == nro_ticket) if (len(funcion) == 9): t_logs_x_nro_ticket = t_logs_x_nro_ticket.filter( func.substr(t_log.id_localidad,0,9) == funcion) else: t_logs_x_nro_ticket = t_logs_x_nro_ticket.filter( funciones.id_espectaculo == funcion) # O sino por todos los tickets de una función, entonces # Lo ordeno y ya le pido que me pase todos los resultados t_logs_x_nro_ticket = t_logs_x_nro_ticket.order_by( tickets.nro_ticket, t_log.id_ticket_log).all() Is there any reason why I can't add or modify values from the database without getting this error? I've never used oracle with sqlalchemy before, but looking at the bottom of the stack trace, is it possible that you have declared your column as some sort of BLOB type but it is actually a simpler data type in the database? Hope that helps, Simon -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
Re: [sqlalchemy] sqlite3 recursivity
well, i thought it would be wiser to ask before :) i don't know if cte is available for all dialects :) i'll give it a try and return asap :) best regards, richard. Em 2014-04-26 15:24, Michael Bayer escreveu: what happens if you just try it? the syntax looks entirely standard. On Apr 26, 2014, at 2:10 PM, Richard Gerd Kuesters rich...@humantech.com.br wrote: hi all! as some already know, sqlite3 version 3.8.x (i'm not quite sure if it's 3.8.x, i might be wrong), but it has now support for recursivity using the with operator: https://sqlite.org/lang_with.html [1] well - probably mike can answear this better - will sqla provide basic support for it, like we already have in postgres using cte? or in the near future we'll only find 3rd part implementations, since it will take time for the world to use this version up? best regards, richard. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy [2]. For more options, visit https://groups.google.com/d/optout [3]. Links: -- [1] https://sqlite.org/lang_with.html [2] http://groups.google.com/group/sqlalchemy [3] https://groups.google.com/d/optout -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.