Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #37580

Re: mysql solution

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'example:': 0.03; 'exception': 0.03; 'args': 0.04; 'attribute': 0.05; 'error:': 0.05; 'python': 0.09; 'exception,': 0.09; 'handler.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'useless': 0.09; 'suggest': 0.11; 'emanuele': 0.16; 'hits': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'typo': 0.16; 'duplicate': 0.17; 'module': 0.19; 'tells': 0.22; 'tried': 0.25; 'header:User-Agent:1': 0.26; '[1]': 0.27; 'header:X -Complaints-To:1': 0.28; 'skip:( 20': 0.28; 'writes:': 0.29; "skip:' 10": 0.30; 'error': 0.30; 'url:python': 0.32; 'print': 0.32; 'skip:s 30': 0.33; 'messages,': 0.33; 'to:addr:python-list': 0.33; 'returning': 0.35; 'received:org': 0.36; 'except': 0.36; 'url:org': 0.36; 'url:library': 0.36; 'subject:: ': 0.38; 'easier': 0.38; 'object': 0.38; 'skip:l 20': 0.38; 'url:docs': 0.38; 'to:addr:python.org': 0.39; 'skip:" 10': 0.40; 'header:Received:5': 0.40; 'your': 0.60; 'please,': 0.62; 'information,': 0.63; '8bit%:100': 0.70; '8bit%:92': 0.70; '2013': 0.84; 'quando': 0.84; 'cutting': 0.93
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Lele Gaifax <lele@metapensiero.it>
Subject Re: mysql solution
Date Thu, 24 Jan 2013 13:22:26 +0100
Organization Nautilus Entertainments
References <88306c73-dfa2-44e1-ab0c-d90dba05be1c@googlegroups.com> <mailman.965.1359026737.2939.python-list@python.org> <774065a6-3d15-4cff-88d8-7f822ed1c0b0@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 8bit
X-Gmane-NNTP-Posting-Host 78-134-78-49.v4.ngi.it
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)
Cancel-Lock sha1:8LrIbqx7FzUregq/vJAnsrLcv80=
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.977.1359030166.2939.python-list@python.org> (permalink)
Lines 46
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1359030166 news.xs4all.nl 6848 [2001:888:2000:d::a6]:49695
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:37580

Show key headers only | View raw


Ferrous Cranus <nikos.gr33k@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@metapensiero.it  |                 -- Fortunato Depero, 1929.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

mysql solution Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-24 03:04 -0800
  Re: mysql solution Chris Angelico <rosuav@gmail.com> - 2013-01-24 22:16 +1100
    Re: mysql solution Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-24 05:31 -0800
      Re: mysql solution Chris Angelico <rosuav@gmail.com> - 2013-01-25 01:46 +1100
    Re: mysql solution Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-24 05:31 -0800
  Re: mysql solution Lele Gaifax <lele@metapensiero.it> - 2013-01-24 12:25 +0100
    Re: mysql solution Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-24 04:01 -0800
      Re: mysql solution Lele Gaifax <lele@metapensiero.it> - 2013-01-24 13:22 +0100
        Re: mysql solution Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-24 05:24 -0800
          Re: mysql solution Lele Gaifax <lele@metapensiero.it> - 2013-01-24 14:37 +0100
            Re: mysql solution Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-24 06:35 -0800
            Re: mysql solution Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-24 06:35 -0800
              Re: mysql solution Duncan Booth <duncan.booth@invalid.invalid> - 2013-01-24 15:19 +0000
                Re: mysql solution Chris Angelico <rosuav@gmail.com> - 2013-01-25 02:27 +1100
                Re: mysql solution Lele Gaifax <lele@metapensiero.it> - 2013-01-24 16:39 +0100
                Re: mysql solution Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-24 10:22 -0800
                Re: mysql solution Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-24 10:22 -0800
        Re: mysql solution Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-24 05:24 -0800
    Re: mysql solution Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-24 04:01 -0800
  Re: mysql solution Chris Angelico <rosuav@gmail.com> - 2013-01-24 22:29 +1100
  Re: mysql solution Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-01-24 15:43 -0500
    Re: mysql solution Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-25 07:43 -0800
      Re: mysql solution Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-01-25 16:56 -0500
        Re: mysql solution Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-26 02:35 -0800
        Re: mysql solution Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-26 02:35 -0800
    Re: mysql solution Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-25 07:43 -0800

csiph-web