Τη Παρασκευή, 25 Ιανουαρίου 2013 11:56:44 μ.μ. UTC+2, ο χρήστης Dennis Lee
Bieber έγραψε:
=
#find the visitor record for the (saved) cID and
current host
cur.execute('''SELECT * FROM visitors WHERE counterID =
%s and host = %s
Τη Πέμπτη, 24 Ιανουαρίου 2013 10:43:59 μ.μ. UTC+2, ο χρήστης Dennis Lee Bieber
έγραψε:
> On Thu, 24 Jan 2013 03:04:46 -0800 (PST), Ferrous Cranus
>
> declaimed the following in
>
> gmane.comp.python.general:
>
>
>
> > # insert new page record in table counters or update it if already exists
Τη Πέμπτη, 24 Ιανουαρίου 2013 5:39:54 μ.μ. UTC+2, ο χρήστης Lele Gaifax έγραψε:
> UPDATE visitors
>
>SET visitors.hits=visitors.hits+1,
>
>visitors.useros=%s,
>
>visitors.browser=%s,
>
>visitors.date=%s
>
> WHERE visitors.pin=(SELECT counters.pin
>
>
Duncan Booth writes:
> I'm not MySQL expert, but something like this might work:
>
> cursor.execute('''UPDATE visitors,counter
> SET visitors.hits=visitors.hits+1, visitors.useros=%s,
> visitors.browser =%s, visitors.date=%s
> WHERE visitors.pin=counter.pin AND counter.page = %s
> AND v
On Fri, Jan 25, 2013 at 2:19 AM, Duncan Booth
wrote:
> Ferrous Cranus wrote:
>
>> I can do that but then i have to use that pin column's value in my
>> next statement.
>>
>> cursor.execute( '''UPDATE visitors SET hits = hits + 1, useros = %s,
>> browser = %s, date = %s WHERE pin = %s AND host = %
Ferrous Cranus wrote:
> I can do that but then i have to use that pin column's value in my
> next statement.
>
> cursor.execute( '''UPDATE visitors SET hits = hits + 1, useros = %s,
> browser = %s, date = %s WHERE pin = %s AND host = %s''', (useros,
> browser, date, pin, host))
I'm not MySQL
On Fri, Jan 25, 2013 at 12:31 AM, Ferrous Cranus wrote:
> Τη Πέμπτη, 24 Ιανουαρίου 2013 1:16:51 μ.μ. UTC+2, ο χρήστης Chris Angelico
> έγραψε:
>> Glad you've listened to at least some of what you've been told. But if
>> you want to be taken seriously on this list, I recommend going back to
>> you
Τη Πέμπτη, 24 Ιανουαρίου 2013 3:37:24 μ.μ. UTC+2, ο χρήστης Lele Gaifax έγραψε:
> How? What's the error message/traceback?
REURNING is not a correct mysql syntax thats why it produces errors.
> If, as Chris said, MySQL does not support the “RETURNING” syntax, you
>
> cannot use that. I gave two
Ferrous Cranus writes:
> The following statement fails.
>
> [code]
> cursor.execute( '''INSERT INTO counters(page, hits) VALUES(%s, %s) RETURNING
> (pin)
> ON DUPLICATE KEY UPDATE hits = hits + 1''',
> (htmlpage, 1) )
> [/code]
How? What's the error message/traceback?
Τη Πέμπτη, 24 Ιανουαρίου 2013 1:16:51 μ.μ. UTC+2, ο χρήστης Chris Angelico
έγραψε:
> On Thu, Jan 24, 2013 at 10:04 PM, Ferrous Cranus
> wrote:
>
> > I;am now convinced the hash solution isn't reversible and also isn't unique.
>
> > I'am trying the database oriented solution.
>
>
>
> Glad yo
column 'pin' is an 5-digit integer auto_increment primary key.
What i want is to insert a new record or update the existing one, if 'pin'
column's value exist. The following statement fails.
[code]
cursor.execute( '''INSERT INTO counters(page, hits) VALUES(%s, %s) RETURNING
(pin)
Ferrous Cranus 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 counter
Τη Πέμπτη, 24 Ιανουαρίου 2013 1:25:20 μ.μ. UTC+2, ο χρήστης Lele Gaifax έγραψε:
> 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 t
On Thu, Jan 24, 2013 at 10:25 PM, Lele Gaifax wrote:
> 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
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 c
On Thu, Jan 24, 2013 at 10:04 PM, Ferrous Cranus wrote:
> I;am now convinced the hash solution isn't reversible and also isn't unique.
> I'am trying the database oriented solution.
Glad you've listened to at least some of what you've been told. But if
you want to be taken seriously on this list,
16 matches
Mail list logo