Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #56224
| Path | csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rosuav@gmail.com> |
| 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; 'else:': 0.03; 'charset:iso-8859-7': 0.04; 'retrieved': 0.05; 'data:': 0.09; 'host,': 0.09; 'python': 0.11; '%s,': 0.16; '(host,': 0.16; 'code?': 0.16; 'fine.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'hits': 0.16; 'sources.': 0.16; 'subject:fails': 0.16; 'subject:when': 0.16; 'applies': 0.16; 'wrote:': 0.18; 'later': 0.20; 'not,': 0.20; 'primary': 0.26; 'values': 0.27; 'header:In-Reply-To:1': 0.27; 'record': 0.27; 'host': 0.29; '[1]': 0.29; 'am,': 0.29; 'message- id:@mail.gmail.com': 0.30; 'code': 0.31; 'sources': 0.33; 'something': 0.35; 'received:google.com': 0.35; 'google': 0.35; 'question,': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; 'read': 0.60; 'expression': 0.60; 'new': 0.61; 'browser': 0.61; 'first': 0.61; 'save': 0.62; 'city': 0.66; 'subject:get': 0.81; 'vid': 0.84; 'visitor': 0.84; '2013': 0.98 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=bFc9z8/U06T5YEUe4nPd35aVls3fum6eBffr8Pg3AGs=; b=fr3LZp+dWmGg5q2NIF3mN4otrFBm9RgTM4Kv634ZLjfKCvR5Dvczird4n3k9q3ockQ Nq2FIoV3PGiP8VMFTh/OgKWfLm07cOConDNxbDymkdgJmQhPyzIS1Blv7kLHNz7gWg7U OEFPCKAmUP6+q3fvabJlXiyxvZRItFw4gVR25TPtUXHoEuM9NDZkva6TQq5vVxlUg8SV ecisGn+TyGpH/sl72gx9uksspZtPGBDL2s978SRqV7N7+3dXLSv28fv08arW5CFvyb63 NEgXNzQ3kGew1NU2Vd//LGZ2hufT/w+bnBzVmFpNhjeynVB0Fn2Bkw/3+5YkkY+/9oEF YSFA== |
| MIME-Version | 1.0 |
| X-Received | by 10.68.130.104 with SMTP id od8mr22200513pbb.29.1381012581796; Sat, 05 Oct 2013 15:36:21 -0700 (PDT) |
| In-Reply-To | <l2pbcs$88r$1@dont-email.me> |
| References | <l2p4o4$4ht$1@dont-email.me> <mailman.743.1380981201.18130.python-list@python.org> <l2p8cl$j06$4@dont-email.me> <mailman.748.1380985965.18130.python-list@python.org> <l2pbcs$88r$1@dont-email.me> |
| Date | Sun, 6 Oct 2013 09:36:21 +1100 |
| Subject | Re: Select fails when cookie tried to get a numeric value |
| From | Chris Angelico <rosuav@gmail.com> |
| To | python-list@python.org |
| Content-Type | text/plain; charset=ISO-8859-7 |
| Content-Transfer-Encoding | quoted-printable |
| 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 | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.763.1381012585.18130.python-list@python.org> (permalink) |
| Lines | 42 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1381012585 news.xs4all.nl 15929 [2001:888:2000:d::a6]:55686 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:56224 |
Show key headers only | View raw
On Sun, Oct 6, 2013 at 1:31 AM, Νίκος Αλεξόπουλος <nikos.gr33k@gmail.com> wrote:
> # find the visitor record for the (saved) cID and current
> host
> cur.execute('''SELECT * FROM visitors WHERE counterID = %s
> and cookieID = %s''', (cID, cookieID) )
>
> data = cur.fetchone() #cookieID is unique
>
> if not data:
>
> # first time visitor on this page, create new record
> cur.execute('''INSERT INTO visitors (counterID,
> cookieID, host, city, useros, browser, ref, lastvisit) VALUES (%s, %s, %s,
> %s, %s, %s, %s, %s)''', (cID, cookieID, host, city, useros, browser, ref,
> lastvisit) )
> else:
> # found the page, save its primary key for later use
> vID = data[0]
> # UPDATE record using retrieved vID
> cur.execute('''UPDATE visitors SET host = %s, city =
> %s, useros = %s, browser = %s, ref= %s, hits = hits + 1, lastvisit = %s
>
> WHERE counterID = %s and cookieID = %s''', (host, city, useros, browser,
> ref, lastvisit, vID, cookieID) )
Do you understand the expression "race condition", and how it applies
to the above code? If not, you MUST read up on that before relying on
code like this, and as that's not a Python question, I recommend
Google and Wikipedia.[1]
ChrisA
[1] Yes, I know they're not primary sources. For something like this,
tertiary sources are going to do him fine.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Select fails when cookie tried to get a numeric value Νίκος Αλεξόπουλος <nikos.gr33k@gmail.com> - 2013-10-05 16:38 +0300
Re: Select fails when cookie tried to get a numeric value Ned Batchelder <ned@nedbatchelder.com> - 2013-10-05 09:53 -0400
Re: Select fails when cookie tried to get a numeric value Νίκος Αλεξόπουλος <nikos.gr33k@gmail.com> - 2013-10-05 17:40 +0300
Re: Select fails when cookie tried to get a numeric value Ned Batchelder <ned@nedbatchelder.com> - 2013-10-05 10:54 -0400
Re: Select fails when cookie tried to get a numeric value Ned Batchelder <ned@nedbatchelder.com> - 2013-10-05 11:12 -0400
Re: Select fails when cookie tried to get a numeric value Νίκος Αλεξόπουλος <nikos.gr33k@gmail.com> - 2013-10-05 18:31 +0300
Re: Select fails when cookie tried to get a numeric value Andreas Perstinger <andipersti@gmail.com> - 2013-10-05 17:47 +0200
Re: Select fails when cookie tried to get a numeric value Chris Angelico <rosuav@gmail.com> - 2013-10-06 09:36 +1100
Re: Select fails when cookie tried to get a numeric value Νίκος Αλεξόπουλος <nikos.gr33k@gmail.com> - 2013-10-05 18:52 +0300
Re: Select fails when cookie tried to get a numeric value Ned Batchelder <ned@nedbatchelder.com> - 2013-10-05 12:08 -0400
Re: Select fails when cookie tried to get a numeric value Νίκος Αλεξόπουλος <nikos.gr33k@gmail.com> - 2013-10-05 19:14 +0300
Re: Select fails when cookie tried to get a numeric value Νίκος Αλεξόπουλος <nikos.gr33k@gmail.com> - 2013-10-05 19:17 +0300
Re: Select fails when cookie tried to get a numeric value Ned Batchelder <ned@nedbatchelder.com> - 2013-10-05 12:42 -0400
Re: Select fails when cookie tried to get a numeric value Νίκος Αλεξόπουλος <nikos.gr33k@gmail.com> - 2013-10-05 19:53 +0300
Re: Select fails when cookie tried to get a numeric value Zero Piraeus <z@etiol.net> - 2013-10-05 12:06 -0300
Re: Select fails when cookie tried to get a numeric value Νίκος Αλεξόπουλος <nikos.gr33k@gmail.com> - 2013-10-05 18:50 +0300
Re: Select fails when cookie tried to get a numeric value Chris Angelico <rosuav@gmail.com> - 2013-10-05 23:59 +1000
Re: Select fails when cookie tried to get a numeric value Νίκος Αλεξόπουλος <nikos.gr33k@gmail.com> - 2013-10-05 17:24 +0300
Re: Select fails when cookie tried to get a numeric value Chris Angelico <rosuav@gmail.com> - 2013-10-06 00:28 +1000
Re: Select fails when cookie tried to get a numeric value Νίκος Αλεξόπουλος <nikos.gr33k@gmail.com> - 2013-10-05 17:30 +0300
Re: Select fails when cookie tried to get a numeric value Ned Batchelder <ned@nedbatchelder.com> - 2013-10-05 10:43 -0400
Re: Select fails when cookie tried to get a numeric value Νίκος Αλεξόπουλος <nikos.gr33k@gmail.com> - 2013-10-05 17:47 +0300
Re: Select fails when cookie tried to get a numeric value Zero Piraeus <z@etiol.net> - 2013-10-05 11:44 -0300
Re: Select fails when cookie tried to get a numeric value MRAB <python@mrabarnett.plus.com> - 2013-10-05 17:51 +0100
Re: Select fails when cookie tried to get a numeric value Νίκος Αλεξόπουλος <nikos.gr33k@gmail.com> - 2013-10-05 17:28 +0300
Re: Select fails when cookie tried to get a numeric value Andreas Perstinger <andipersti@gmail.com> - 2013-10-05 18:56 +0200
Re: Select fails when cookie tried to get a numeric value Νίκος Αλεξόπουλος <nikos.gr33k@gmail.com> - 2013-10-05 20:38 +0300
Re: Select fails when cookie tried to get a numeric value Benjamin Rovny <rdr.vladimir@gmail.com> - 2013-10-05 09:35 -0500
Re: Select fails when cookie tried to get a numeric value Terry Reedy <tjreedy@udel.edu> - 2013-10-05 18:06 -0400
Re: Select fails when cookie tried to get a numeric value Denis McMahon <denismfmcmahon@gmail.com> - 2013-10-05 23:36 +0000
Re: Select fails when cookie tried to get a numeric value Νίκος Αλεξόπουλος <nikos.gr33k@gmail.com> - 2013-10-06 08:20 +0300
Re: Select fails when cookie tried to get a numeric value Denis McMahon <denismfmcmahon@gmail.com> - 2013-10-06 14:57 +0000
Re: Select fails when cookie tried to get a numeric value Piet van Oostrum <piet@vanoostrum.org> - 2013-10-06 22:16 -0400
csiph-web