Re: Updating a filename's counter value failed each time

2013-06-17 Thread Νίκος
Στις 18/6/2013 4:42 πμ, ο/η Dennis Lee Bieber έγραψε: Do you ever COMMIT the changes. cur.execute("update anything set something = whatever where that = this") without doing a con.commit() is just going to rollback the changes. committing the changes inst necessary neither i

Re: Updating a filename's counter value failed each time

2013-06-17 Thread Νίκος
Στις 18/6/2013 2:30 πμ, ο/η Dennis Lee Bieber έγραψε: In the case of MySQLdb -- IT will wrap each argument with quotes, along with escaping any special characters. Even if the query is something like: http://superhost.gr/cgi-bin/files.py?filename="Select."; From what exactly the

Re: Updating a filename's counter value failed each time

2013-06-17 Thread Νίκος
Finally i made it!! Here it is: # = # Have 1:1 mapping of files <-> database records, delete spurious # ==

Re: Updating a filename's counter value failed each time

2013-06-17 Thread Steven D'Aprano
On Mon, 17 Jun 2013 19:39:16 +0300, Simpleton wrote: > Hello again, something simple this time: Have you read these links yet? http://sscce.org/‎ http://www.catb.org/esr/faqs/smart-questions.html‎ Especially the first one. Until you read it, and follow it's advice, I will not answer your ques

Re: Updating a filename's counter value failed each time

2013-06-17 Thread Νίκος
Στις 18/6/2013 1:22 πμ, ο/η MRAB έγραψε: On 17/06/2013 21:44, John Gordon wrote: In Alister writes: > #update file's counter if cookie does not exist cur.execute('''UPDATE > files SET hits = hits + 1, host = %s, lastvisit = > %s WHERE url = %s''', (host, lastvisit, filename) ) > > if cur.row

Re: Updating a filename's counter value failed each time

2013-06-17 Thread MRAB
On 17/06/2013 21:44, John Gordon wrote: In Alister writes: > #update file's counter if cookie does not exist cur.execute('''UPDATE > files SET hits = hits + 1, host = %s, lastvisit = > %s WHERE url = %s''', (host, lastvisit, filename) ) > > if cur.rowcount: >print( " database has

Re: Updating a filename's counter value failed each time

2013-06-17 Thread John Gordon
In Alister writes: > > #update file's counter if cookie does not exist cur.execute('''UPDATE > > files SET hits = hits + 1, host = %s, lastvisit = > > %s WHERE url = %s''', (host, lastvisit, filename) ) > > > > if cur.rowcount: > > print( " database has been affected" ) > > > > ind

Re: Updating a filename's counter value failed each time

2013-06-17 Thread Alister
On Mon, 17 Jun 2013 20:26:57 +, Alister wrote: > On Mon, 17 Jun 2013 22:30:57 +0300, Νίκος wrote: > >> On 17/6/2013 10:05 μμ, Alister wrote: >>> You are correct Nicos, passing the values as a parameter list does >>> protect you from SQL injection JT has made an error. >> >> Even if the query

Re: Updating a filename's counter value failed each time

2013-06-17 Thread Alister
On Mon, 17 Jun 2013 20:44:03 +, John Gordon wrote: > In Alister > writes: > >> > #update file's counter if cookie does not exist cur.execute('''UPDATE >> > files SET hits = hits + 1, host = %s, lastvisit = >> > %s WHERE url = %s''', (host, lastvisit, filename) ) >> > >> > if cur.rowcount:

Re: Updating a filename's counter value failed each time

2013-06-17 Thread Alister
On Mon, 17 Jun 2013 22:28:47 +0300, Νίκος wrote: > On 17/6/2013 10:19 μμ, John Gordon wrote: >> Print the cur.rowcount attribute, which contains the number of rows >> that were affected by the update. If it's zero, that should tell you >> something. > > > #update file's counter if cookie does n

Re: Updating a filename's counter value failed each time

2013-06-17 Thread Alister
On Mon, 17 Jun 2013 19:16:02 +, Jens Thoms Toerring wrote: > MRAB wrote: >> On 17/06/2013 19:32, Jens Thoms Toerring wrote: >> > As I wrote you need *single* quotes around strings in SQL statements. >> > Double quotes won't do - this is SQL and not Python so you're dealing >> > with a differe

Re: Updating a filename's counter value failed each time

2013-06-17 Thread Alister
On Mon, 17 Jun 2013 22:30:57 +0300, Νίκος wrote: > On 17/6/2013 10:05 μμ, Alister wrote: >> You are correct Nicos, passing the values as a parameter list does >> protect you from SQL injection JT has made an error. > > Even if the query is somehting like: > > http://superhost.gr/cgi-bin/files.py

Re: Updating a filename's counter value failed each time

2013-06-17 Thread Νίκος
On 17/6/2013 10:05 μμ, Alister wrote: You are correct Nicos, passing the values as a parameter list does protect you from SQL injection JT has made an error. Even if the query is somehting like: http://superhost.gr/cgi-bin/files.py?filename="Select."; From what exactly the comma protects

Re: Updating a filename's counter value failed each time

2013-06-17 Thread Νίκος
On 17/6/2013 10:19 μμ, John Gordon wrote: Print the cur.rowcount attribute, which contains the number of rows that were affected by the update. If it's zero, that should tell you something. #update file's counter if cookie does not exist cur.execute('''UPDATE files SET hits = hits + 1, host =

Re: Updating a filename's counter value failed each time

2013-06-17 Thread John Gordon
In Simpleton writes: > if form.getvalue('filename'): > cur.execute('''UPDATE files SET hits = hits + 1, host = %s, lastvisit = > %s WHERE url = %s''', (host, lastvisit, filename) ) Add an 'else' statement above that prints something, so you will at least know if the UPDATE statement is e

Re: Updating a filename's counter value failed each time

2013-06-17 Thread Jens Thoms Toerring
MRAB wrote: > On 17/06/2013 19:32, Jens Thoms Toerring wrote: > > As I wrote you need *single* quotes around strings in > > SQL statements. Double quotes won't do - this is SQL > > and not Python so you're dealing with a different lan- > > guage and thus different rules apply. The triple single >

Re: Updating a filename's counter value failed each time

2013-06-17 Thread Alister
On Mon, 17 Jun 2013 21:06:16 +0300, Νίκος wrote: > > But the comma inside the execute statement doesn't protect me from such > actions opposed when i was using a substitute operator? You are correct Nicos, passing the values as a parameter list does protect you from SQL injection JT has made an

Re: Updating a filename's counter value failed each time

2013-06-17 Thread MRAB
On 17/06/2013 19:32, Jens Thoms Toerring wrote: Νίκος wrote: On 17/6/2013 8:54 μμ, Jens Thoms Toerring wrote: > Also take care to check the filename you insert - a malicous > user might cobble together a file name that is actually a SQL > statement and then do nasty things to your database. I.e

Re: Updating a filename's counter value failed each time

2013-06-17 Thread Jens Thoms Toerring
Νίκος wrote: > On 17/6/2013 8:54 μμ, Jens Thoms Toerring wrote: > > Also take care to check the filename you insert - a malicous > > user might cobble together a file name that is actually a SQL > > statement and then do nasty things to your database. I.e. never > > insert values you received from

Re: Updating a filename's counter value failed each time

2013-06-17 Thread Νίκος
On 17/6/2013 8:54 μμ, Jens Thoms Toerring wrote: Also take care to check the filename you insert - a malicous user might cobble together a file name that is actually a SQL statement and then do nasty things to your database. I.e. never insert values you received from a user without checking them.

Re: Updating a filename's counter value failed each time

2013-06-17 Thread Jens Thoms Toerring
In article you wrote: > After a user selects a file from the form, that sleection of his can be > found form reading the variable 'filename' > If the filename already exists in to the database i want to update its > counter and that is what i'm trying to accomplish by: > --- > if form.

Re: Updating a filename's counter value failed each time

2013-06-17 Thread Νίκος
On 17/6/2013 8:40 μμ, MRAB wrote: On 17/06/2013 17:39, Simpleton wrote: Hello again, something simple this time: After a user selects a file from the form, that sleection of his can be found form reading the variable 'filename' If the filename already exists in to the database i want to update

Re: Updating a filename's counter value failed each time

2013-06-17 Thread John Gordon
In Simpleton writes: > Hello again, something simple this time: > After a user selects a file from the form, that sleection of his can be > found form reading the variable 'filename' > If the filename already exists in to the database i want to update its > counter and that is what i'm tryin

Re: Updating a filename's counter value failed each time

2013-06-17 Thread MRAB
On 17/06/2013 17:39, Simpleton wrote: Hello again, something simple this time: After a user selects a file from the form, that sleection of his can be found form reading the variable 'filename' If the filename already exists in to the database i want to update its counter and that is what i'm t

Updating a filename's counter value failed each time

2013-06-17 Thread Simpleton
Hello again, something simple this time: After a user selects a file from the form, that sleection of his can be found form reading the variable 'filename' If the filename already exists in to the database i want to update its counter and that is what i'm trying to accomplish by: --