Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder2.hal-mli.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'args': 0.04; 'attribute': 0.05; 'error:': 0.05; 'mysql,': 0.07; 'python': 0.09; 'fetch': 0.09; 'record.': 0.09; 'to:addr:comp.lang.python': 0.09; 'cc:addr :python-list': 0.10; '"insert': 0.16; '(%s,': 0.16; 'emanuele': 0.16; 'great!': 0.16; 'hits': 0.16; 'simplest': 0.16; 'duplicate': 0.17; 'tells': 0.22; 'cc:2**0': 0.23; 'insert': 0.23; 'statement': 0.23; 'cc:no real name:2**0': 0.24; 'tried': 0.25; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header :User-Agent:1': 0.26; 'select': 0.26; 'values': 0.26; 'skip:( 20': 0.28; 'hash': 0.29; 'writes:': 0.29; "skip:' 10": 0.30; 'error': 0.30; 'could': 0.32; 'print': 0.32; 'skip:s 30': 0.33; "can't": 0.34; 'received:google.com': 0.34; 'returning': 0.35; 'doing': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'except': 0.36; 'should': 0.36; 'execute': 0.37; 'received:209': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'object': 0.38; 'supports': 0.38; 'page': 0.38; 'where': 0.40; 'skip:" 10': 0.40; 'pin': 0.65; '8bit%:100': 0.70; '8bit%:92': 0.70; '2013': 0.84; 'quando': 0.84; 'unique.': 0.84; 'convinced': 0.93 X-Received: by 10.50.13.225 with SMTP id k1mr403790igc.4.1359028900997; Thu, 24 Jan 2013 04:01:40 -0800 (PST) Newsgroups: comp.lang.python Date: Thu, 24 Jan 2013 04:01:40 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=94.68.70.179; posting-account=DYJQ-woAAACEPH85Au2BhUVfFTfSfVa4 References: <88306c73-dfa2-44e1-ab0c-d90dba05be1c@googlegroups.com> User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-IP: 94.68.70.179 MIME-Version: 1.0 Subject: Re: mysql solution From: Ferrous Cranus To: comp.lang.python@googlegroups.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Message-ID: Lines: 76 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1359028909 news.xs4all.nl 6842 [2001:888:2000:d::a6]:36053 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:37578 =CE=A4=CE=B7 =CE=A0=CE=AD=CE=BC=CF=80=CF=84=CE=B7, 24 =CE=99=CE=B1=CE=BD=CE= =BF=CF=85=CE=B1=CF=81=CE=AF=CE=BF=CF=85 2013 1:25:20 =CE=BC.=CE=BC. UTC+2, = =CE=BF =CF=87=CF=81=CE=AE=CF=83=CF=84=CE=B7=CF=82 Lele Gaifax =CE=AD=CE=B3= =CF=81=CE=B1=CF=88=CE=B5: > Ferrous Cranus writes: >=20 >=20 >=20 > > I;am now convinced the hash solution isn't reversible and also isn't >=20 > > unique. >=20 >=20 >=20 > Great! >=20 >=20 >=20 > > how is the mysql statement is going to find the 'pin' to update the >=20 > > specific record. >=20 >=20 >=20 > The simplest way is to execute a SELECT just after the insertion, doing >=20 > a >=20 >=20 >=20 > SELECT pin FROM counters WHERE page =3D %s >=20 >=20 >=20 > I don't use MySQL, so I can't say if it supports "INSERT ... RETURNING ..= ." >=20 > SQL syntax: should it, then you could insert the data and fetch >=20 > the pin in one shot, with something like >=20 >=20 >=20 > INSERT INTO counters (page, hits) VALUES (%s, %s) RETURNING (pin) >=20 >=20 >=20 > ciao, lele. >=20 > -- >=20 > nickname: Lele Gaifax | Quando vivr=C3=B2 di quello che ho pensato ieri >=20 > real: Emanuele Gaifas | comincer=C3=B2 ad aver paura di chi mi copia. >=20 > lele@metapensiero.it | -- Fortunato Depero, 1929. I just tried this statement: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D cursor.execute( '''INSERT INTO counters(page, hits) VALUES(%s, %s) RETURNIN= G (pin)=20 ON DUPLICATE KEY UPDATE hits =3D hits + 1''', (htmlpage, 1) ) except MySQLdb.Error, e: print ( "Query Error: ", sys.exc_info()[1].excepinfo()[2] ) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D and the error python tells me is: : 'ProgrammingError' object has no attrib= ute 'excepinfo'=20 args =3D ("'ProgrammingError' object has no attribute 'excepinfo'",)= =20 message =3D "'ProgrammingError' object has no attribute 'excepinfo'"