Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!newsfeed.straub-nv.de!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!newsfeed.eweka.nl!eweka.nl!feeder3.eweka.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: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'mysql,': 0.07; 'fetch': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'record.': 0.09; '"insert': 0.16; '(%s,': 0.16; 'emanuele': 0.16; 'great!': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'simplest': 0.16; 'insert': 0.23; 'statement': 0.23; 'header :User-Agent:1': 0.26; 'select': 0.26; 'values': 0.26; 'header:X -Complaints-To:1': 0.28; 'hash': 0.29; 'writes:': 0.29; 'could': 0.32; 'to:addr:python-list': 0.33; "can't": 0.34; 'returning': 0.35; 'doing': 0.35; 'something': 0.35; 'received:org': 0.36; 'should': 0.36; 'execute': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'supports': 0.38; 'page': 0.38; 'to:addr:python.org': 0.39; 'where': 0.40; 'header:Received:5': 0.40; 'pin': 0.65; 'quando': 0.84; 'unique.': 0.84; 'convinced': 0.93 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Lele Gaifax Subject: Re: mysql solution Date: Thu, 24 Jan 2013 12:25:20 +0100 Organization: Nautilus Entertainments References: <88306c73-dfa2-44e1-ab0c-d90dba05be1c@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:QPhnbap7I5+UvW97OZ23wvhUInI= 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: , Newsgroups: comp.lang.python Message-ID: Lines: 27 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1359026737 news.xs4all.nl 6861 [2001:888:2000:d::a6]:57448 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:37566 Ferrous Cranus writes: > I;am now convinced the hash solution isn't reversible and also isn't > unique. Great! > how is the mysql statement is going to find the 'pin' to update the > specific record. The simplest way is to execute a SELECT just after the insertion, doing a SELECT pin FROM counters WHERE page = %s I don't use MySQL, so I can't say if it supports "INSERT ... RETURNING ..." SQL syntax: should it, then you could insert the data and fetch the pin in one shot, with something like INSERT INTO counters (page, hits) VALUES (%s, %s) RETURNING (pin) ciao, lele. -- 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.