mysql solution
Lele Gaifax
lele at metapensiero.it
Thu Jan 24 07:22:26 EST 2013
Ferrous Cranus <nikos.gr33k at gmail.com> writes:
> Τη Πέμπτη, 24 Ιανουαρίου 2013 1:25:20 μ.μ. UTC+2, ο χρήστης Lele Gaifax έγραψε:
Please, trim your response messages, cutting away useless details.
>
> I just tried this statement:
>
> ==========================================
> cursor.execute( '''INSERT INTO counters(page, hits) VALUES(%s, %s) RETURNING (pin)
> ON DUPLICATE KEY UPDATE hits = hits + 1''', (htmlpage, 1) )
> except MySQLdb.Error, e:
> print ( "Query Error: ", sys.exc_info()[1].excepinfo()[2] )
> ==========================================
>
> and the error python tells me is:
>
> <type 'exceptions.AttributeError'>: 'ProgrammingError' object has no attribute 'excepinfo'
> args = ("'ProgrammingError' object has no attribute 'excepinfo'",)
> message = "'ProgrammingError' object has no attribute 'excepinfo'"
As the error message says, you have a typo in your exception handler.
I suggest using the logging[1] module to print out such information, as it
expose a bunch of handy methods that make it easier to print the
exception, for example:
...
except MySQLdb.Error:
logging.error('Query Error!', exc_info=True)
or even
...
except MySQLdb.Error:
logging.exception('Query Error!')
ciao, lele.
[1] http://docs.python.org/2.7/library/logging.html#module-logging
--
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
lele at metapensiero.it | -- Fortunato Depero, 1929.
More information about the Python-list
mailing list