[Python-es] OFFTopic: error SQL

Diego Uribe Gamez diego.uribe.gamez en gmail.com
Mie Ene 23 20:22:05 CET 2013


Estoy haciendo un query que me dice cuantas veces hoy fue ingresado un
producto por id, pero me sale un error cuando intento realizar
la búsqueda sobre dos columnas, en cambio si lo hago sobre una queda bien.

Este sale bien:
--------------------------------------------------------------------
query = "SELECT COUNT(*) FROM tienda_registro WHERE fecha_servidor =
'2013-01-22'"
--------------------------------------------------------------------

Este que consulta el conteo usando dos columnas sale mal
--------------------------------------------------------------------
query = "SELECT COUNT(*) FROM tienda_registro WHERE id_producto = 65656 ,
fecha_servidor = '2013-01-22'"

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 174, in
execute
    self.errorhandler(self, exc, value)
  File "/usr/lib/python2.7/dist-packages/MySQLdb/connections.py", line 36,
in defaulterrorhandler
    raise errorclass, errorvalue
_mysql_exceptions.ProgrammingError: (1064, "You have an error in your SQL
syntax; check the manual that corresponds to your MySQL server version for
the right syntax to use near ' fecha_servidor = '2013-01-22'' at line 1")
--------------------------------------------------------------------

Alguien me podría decir que esta mal?

Gracias.

-- 
 *Diego Alonso Uribe Gamez*
------------------------------

*Desarrollador web*

Twitter: @DiegoUG <http://www.twitter.com/DiegoUG>

Google+: http://gplus.to/diegoug
------------------------------
------------ próxima parte ------------
Se ha borrado un adjunto en formato HTML...
URL: <http://mail.python.org/pipermail/python-es/attachments/20130123/d42bf276/attachment.html>


Más información sobre la lista de distribución Python-es