Re: mysql solution

2013-01-26 Thread Ferrous Cranus
Τη Παρασκευή, 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

Re: mysql solution

2013-01-25 Thread Ferrous Cranus
Τη Πέμπτη, 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

Re: mysql solution

2013-01-24 Thread Ferrous Cranus
Τη Πέμπτη, 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 > >

Re: mysql solution

2013-01-24 Thread Lele Gaifax
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

Re: mysql solution

2013-01-24 Thread Chris Angelico
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 = %

Re: mysql solution

2013-01-24 Thread Duncan Booth
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

Re: mysql solution

2013-01-24 Thread Chris Angelico
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

Re: mysql solution

2013-01-24 Thread Ferrous Cranus
Τη Πέμπτη, 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

Re: mysql solution

2013-01-24 Thread Lele Gaifax
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?

Re: mysql solution

2013-01-24 Thread Ferrous Cranus
Τη Πέμπτη, 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

Re: mysql solution

2013-01-24 Thread Ferrous Cranus
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)

Re: mysql solution

2013-01-24 Thread Lele Gaifax
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

Re: mysql solution

2013-01-24 Thread Ferrous Cranus
Τη Πέμπτη, 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

Re: mysql solution

2013-01-24 Thread Chris Angelico
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

Re: mysql solution

2013-01-24 Thread 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 the > specific record. The simplest way is to execute a SELECT just after the insertion, doing a SELECT pin FROM c

Re: mysql solution

2013-01-24 Thread 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 you've listened to at least some of what you've been told. But if you want to be taken seriously on this list,

mysql solution

2013-01-24 Thread Ferrous Cranus
# insert new page record in table counters or update it if already exists try: cursor.execute( '''INSERT INTO counters(page, hits) VALUES(%s, %s) ON DUPLICATE KEY UPDATE hits = hits + 1''', (htmlpage, 1) )