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.ar<javascript:>> > 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.