Re: Escaping confusion with Python 3 + MySQL

2020-04-21 Thread moorthy . rs
On Sunday, March 26, 2017 at 7:55:09 PM UTC+5:30, Νίκος Βέργος wrote: > Τη Κυριακή, 26 Μαρτίου 2017 - 5:19:27 μ.μ. UTC+3, ο χρήστης Ian έγραψε: > > > You need to change the placeholders back. The poster who told you to > > replace them was misinformed. > > okey altered them back to > > cur.execu

Re: String escaping utility for Python (was: Rawest raw string literals)

2017-04-23 Thread Mikhail V
On 23 April 2017 at 05:03, MRAB wrote: > On 2017-04-22 23:30, Mikhail V wrote: >> >> On 20 April 2017 at 23:54, MRAB wrote: >> > On 2017-04-20 22:03, Mikhail V wrote: >> >> >> >> On 20 April 2017 at 22:43, Random832 wrote: >> >>> [snip] >> >>> >> >>> The best solution I can think of is to have a

Re: String escaping utility for Python (was: Rawest raw string literals)

2017-04-22 Thread MRAB
On 2017-04-22 23:30, Mikhail V wrote: On 20 April 2017 at 23:54, MRAB wrote: > On 2017-04-20 22:03, Mikhail V wrote: >> >> On 20 April 2017 at 22:43, Random832 wrote: >>> [snip] >>> >>> The best solution I can think of is to have a text editor designed to >>> parse a string literal, spawn a nes

Re: String escaping utility for Python (was: Rawest raw string literals)

2017-04-22 Thread Chris Angelico
On Sun, Apr 23, 2017 at 12:30 PM, eryk sun wrote: > The X terminals that I've used make it easy to copy text to the > clipboard. For Windows, it's a pain prior to Windows 10 since the > legacy console only does rectangular selection. The Windows 10 console > does line-wrapped selection. This is t

Re: String escaping utility for Python (was: Rawest raw string literals)

2017-04-22 Thread eryk sun
On Sun, Apr 23, 2017 at 2:06 AM, Mikhail V wrote: > > But are you joking, right? Even if it worked, how can this be convinient, > e.g. in console one cannot even select and copy paste easily. The X terminals that I've used make it easy to copy text to the clipboard. For Windows, it's a pain prior

Re: String escaping utility for Python (was: Rawest raw string literals)

2017-04-22 Thread Chris Angelico
On Sun, Apr 23, 2017 at 12:06 PM, Mikhail V wrote: > Don't know, all I see is "SyntaxError: invalid syntax" if I paste > there some text. > Try to paste e.g. this: > "ffmpeg -i "D:\VIDEO\exp\intro.mp4" -vf "crop=1280:720:0:40, > scale=640:360" -pix_fmt yuv420p "D:\ART\0MASTER_UMST\yt_pico.mp4""

Re: String escaping utility for Python (was: Rawest raw string literals)

2017-04-22 Thread Mikhail V
On 23 April 2017 at 02:33, Chris Angelico wrote: > On Sun, Apr 23, 2017 at 10:19 AM, Mikhail V wrote: >> On 23 April 2017 at 00:48, Chris Angelico wrote: >>> On Sun, Apr 23, 2017 at 8:30 AM, Mikhail V wrote: The purpose is simple: reduce manual work to escape special characters in str

Re: String escaping utility for Python (was: Rawest raw string literals)

2017-04-22 Thread Chris Angelico
On Sun, Apr 23, 2017 at 10:19 AM, Mikhail V wrote: > On 23 April 2017 at 00:48, Chris Angelico wrote: >> On Sun, Apr 23, 2017 at 8:30 AM, Mikhail V wrote: >>> The purpose is simple: reduce manual work to escape special >>> characters in string literals (and escape non-ASCII characters). >>> >>>

Re: String escaping utility for Python (was: Rawest raw string literals)

2017-04-22 Thread Mikhail V
On 23 April 2017 at 00:48, Chris Angelico wrote: > On Sun, Apr 23, 2017 at 8:30 AM, Mikhail V wrote: >> The purpose is simple: reduce manual work to escape special >> characters in string literals (and escape non-ASCII characters). >> >> Simple usage scenario: >> - I have a long command-line stri

Re: String escaping utility for Python (was: Rawest raw string literals)

2017-04-22 Thread Chris Angelico
On Sun, Apr 23, 2017 at 8:30 AM, Mikhail V wrote: > The purpose is simple: reduce manual work to escape special > characters in string literals (and escape non-ASCII characters). > > Simple usage scenario: > - I have a long command-line string in some text editor. > - Copy this string and paste in

String escaping utility for Python (was: Rawest raw string literals)

2017-04-22 Thread Mikhail V
On 20 April 2017 at 23:54, MRAB wrote: > On 2017-04-20 22:03, Mikhail V wrote: >> >> On 20 April 2017 at 22:43, Random832 wrote: >>> [snip] >>> >>> The best solution I can think of is to have a text editor designed to >>> parse a string literal, spawn a nested editor with the unescaped >>> conten

Re: Escaping confusion with Python 3 + MySQL

2017-03-27 Thread Jussi Piitulainen
Gregory Ewing writes: > Νίκος Βέργος wrote: > >> Its still a mystery to em whay this fails syntactically when at the >> same time INSERT works like that. > > I don't think *anyone* understands why SQL was designed with > INSERT and UPDATE having completely different syntaxes. > But it was, and we

Re: Escaping confusion with Python 3 + MySQL

2017-03-27 Thread Gregory Ewing
Νίκος Βέργος wrote: Its still a mystery to em whay this fails syntactically when at the same time INSERT works like that. I don't think *anyone* understands why SQL was designed with INSERT and UPDATE having completely different syntaxes. But it was, and we have to live with it. -- Greg -- ht

Re: Escaping confusion with Python 3 + MySQL

2017-03-27 Thread Νίκος Βέργος
Thank you very much Johann. i was using print(update wuery here) and i was seeing that print was able to parser the query and that consused me as to why execute wont do the same since with print all values was gettign substituted. of course pymysql doesnt behave the same with print but until i fu

Re: Escaping confusion with Python 3 + MySQL

2017-03-27 Thread Johann Spies
Νίκος, I am glad that you solved the problem. I am not using mysql but postgresql. When I get a problem using python to communicate with the database, one of my first steps will be to determine whether the error is a python (maybe psycopg-related) related error or a database error. What I do th

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread Νίκος Βέργος
Τη Δευτέρα, 27 Μαρτίου 2017 - 6:00:34 π.μ. UTC+3, ο χρήστης Chris Angelico έγραψε: > On Mon, Mar 27, 2017 at 1:52 PM, Νίκος Βέργος wrote: > > Its NOT that i have not read it exactly, but for some strange reason i was > > under the belief that the way i had syntactically typed the UPDATE query >

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread Chris Angelico
On Mon, Mar 27, 2017 at 1:52 PM, Νίκος Βέργος wrote: > Its NOT that i have not read it exactly, but for some strange reason i was > under the belief that the way i had syntactically typed the UPDATE query was > correctly and more consistent and similar to thr INSERT query and it was > prefered

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread Νίκος Βέργος
Τη Δευτέρα, 27 Μαρτίου 2017 - 5:43:01 π.μ. UTC+3, ο χρήστης Chris Angelico έγραψε: > On Mon, Mar 27, 2017 at 1:39 PM, Νίκος Βέργος wrote: > >> MariaDB / MySQL shows part of your SQL from where they failed to parse. > >> In your case, your MariaDB can't parse from '(' > >> LIKE clause is not probl

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread Chris Angelico
On Mon, Mar 27, 2017 at 1:39 PM, Νίκος Βέργος wrote: >> MariaDB / MySQL shows part of your SQL from where they failed to parse. >> In your case, your MariaDB can't parse from '(' >> LIKE clause is not problem for this issue? > > Yes indeed it is. > I was just so sure that UPDATE was working like I

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread Νίκος Βέργος
Τη Δευτέρα, 27 Μαρτίου 2017 - 2:27:31 π.μ. UTC+3, ο χρήστης INADA Naoki έγραψε: > > i dont have to update table set column1 = this value, column2=that value and > > so on > > Why do you think so? Did you really read the manual? > > mysql> create table test_update (a int primary key, b int, c int

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread Steve D'Aprano
On Mon, 27 Mar 2017 07:13 am, Νίκος Βέργος wrote: > OMG!!! It actually worked! > > Can't believe that 3 days in a row i have tried everything concerning > string manipulation and mysql escaping nd the error was the UPDATE > itself You tried everything except what we tol

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread INADA Naoki
> i dont have to update table set column1 = this value, column2=that value and > so on Why do you think so? Did you really read the manual? mysql> create table test_update (a int primary key, b int, c int); Query OK, 0 rows affected (0.02 sec) mysql> insert into test_update values (1, 2, 3); Qu

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread breamoreboy
On Sunday, March 26, 2017 at 8:33:49 PM UTC+1, Νίκος Βέργος wrote: > Τη Κυριακή, 26 Μαρτίου 2017 - 10:23:27 μ.μ. UTC+3, ο χρήστης > bream...@gmail.com έγραψε: > > On Sunday, March 26, 2017 at 4:11:54 PM UTC+1, Νίκος Βέργος wrote: > > > Τη Κυριακή, 26 Μαρτίου 2017 - 5:49:00 μ.μ. UTC+3, ο χρήστης Ia

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread breamoreboy
On Sunday, March 26, 2017 at 4:11:54 PM UTC+1, Νίκος Βέργος wrote: > Τη Κυριακή, 26 Μαρτίου 2017 - 5:49:00 μ.μ. UTC+3, ο χρήστης Ian έγραψε: > > > The database wrapper won't do substitution into the middle of a string > > like that. Either concatenate the literal %'s on in the SQL statement > > or

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread Νίκος Βέργος
Τη Κυριακή, 26 Μαρτίου 2017 - 11:59:21 μ.μ. UTC+3, ο χρήστης Larry Hudson έγραψε: > On 03/26/2017 01:21 AM, Νίκος Βέργος wrote: > > print('''UPDATE visitors SET (pagesID, host, ref, location, useros, > > browser, visits) VALUES (%s, %s, %s, %s, %s, %s, %s) WHERE host LIKE > > "%s"''', (pID, doma

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread Larry Hudson via Python-list
On 03/26/2017 01:21 AM, Νίκος Βέργος wrote: print('''UPDATE visitors SET (pagesID, host, ref, location, useros, browser, visits) VALUES (%s, %s, %s, %s, %s, %s, %s) WHERE host LIKE "%s"''', (pID, domain, ref, location, useros, browser, lastvisit, domain) ) prints out: UPDATE visitors SET (pag

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread Νίκος Βέργος
try this: > > cur.execute('''UPDATE visitors SET pagesID=%s, host=%s, ref=%s, location=%s, > useros=%s, browser=%s, visits=%s WHERE host LIKE %s''', (pID, domain, ref, > location, useros, browser, lastvisit, domain_query) ) OMG!!! It actually wor

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread Νίκος Βέργος
Τη Κυριακή, 26 Μαρτίου 2017 - 10:56:07 μ.μ. UTC+3, ο χρήστης Chris Angelico έγραψε: > On Mon, Mar 27, 2017 at 6:33 AM, Νίκος Βέργος wrote: > > Since i'm incopetent as you suggest i'am show us your level of skills and > > expertise and provide a solution, otherwise you are also what you claim of

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread Chris Angelico
On Mon, Mar 27, 2017 at 6:33 AM, Νίκος Βέργος wrote: > Since i'm incopetent as you suggest i'am show us your level of skills and > expertise and provide a solution, otherwise you are also what you claim of me. It's not his problem. An expert does not have to provide solutions to prove his expert

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread Νίκος Βέργος
Τη Κυριακή, 26 Μαρτίου 2017 - 10:23:27 μ.μ. UTC+3, ο χρήστης bream...@gmail.com έγραψε: > On Sunday, March 26, 2017 at 4:11:54 PM UTC+1, Νίκος Βέργος wrote: > > Τη Κυριακή, 26 Μαρτίου 2017 - 5:49:00 μ.μ. UTC+3, ο χρήστης Ian έγραψε: > > > > > The database wrapper won't do substitution into the mi

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread Νίκος Βέργος
Τη Κυριακή, 26 Μαρτίου 2017 - 10:04:31 μ.μ. UTC+3, ο χρήστης Chris Angelico έγραψε: > On Mon, Mar 27, 2017 at 5:52 AM, Νίκος Βέργος wrote: > > Τη Κυριακή, 26 Μαρτίου 2017 - 9:32:13 μ.μ. UTC+3, ο χρήστης Chris Angelico > > έγραψε: > >> On Mon, Mar 27, 2017 at 4:54 AM, Νίκος Βέργος wrote: > >> >

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread Chris Angelico
On Mon, Mar 27, 2017 at 5:52 AM, Νίκος Βέργος wrote: > Τη Κυριακή, 26 Μαρτίου 2017 - 9:32:13 μ.μ. UTC+3, ο χρήστης Chris Angelico > έγραψε: >> On Mon, Mar 27, 2017 at 4:54 AM, Νίκος Βέργος wrote: >> > Τη Κυριακή, 26 Μαρτίου 2017 - 8:06:07 μ.μ. UTC+3, ο χρήστης INADA Naoki >> > έγραψε: >> >> Rea

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread Νίκος Βέργος
Τη Κυριακή, 26 Μαρτίου 2017 - 8:58:55 μ.μ. UTC+3, ο χρήστης alister έγραψε: > On Sun, 26 Mar 2017 07:43:51 -0700, Νίκος Βέργος wrote: > > > Τη Κυριακή, 26 Μαρτίου 2017 - 5:38:57 μ.μ. UTC+3, ο χρήστης alister > > έγραψε: > >> On Sun, 26 Mar 2017 07:24:49 -0700, Νίκος Βέργος wrote: > >> > >> > Τη Κ

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread Νίκος Βέργος
Τη Κυριακή, 26 Μαρτίου 2017 - 9:32:13 μ.μ. UTC+3, ο χρήστης Chris Angelico έγραψε: > On Mon, Mar 27, 2017 at 4:54 AM, Νίκος Βέργος wrote: > > Τη Κυριακή, 26 Μαρτίου 2017 - 8:06:07 μ.μ. UTC+3, ο χρήστης INADA Naoki > > έγραψε: > >> Read my mail again. > >> > >> > This error came from MySQL. If t

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread breamoreboy
On Sunday, March 26, 2017 at 3:11:50 PM UTC+1, Ian wrote: > On Sun, Mar 26, 2017 at 7:39 AM, MeV wrote: > > On Sunday, March 26, 2017 at 6:34:30 AM UTC-7, Νίκος Βέργος wrote: > >> with import cgitb; cgitb.enable() > >> > >> ProgrammingError(1064, "You have an error in your SQL syntax; check the >

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread Chris Angelico
On Mon, Mar 27, 2017 at 4:54 AM, Νίκος Βέργος wrote: > Τη Κυριακή, 26 Μαρτίου 2017 - 8:06:07 μ.μ. UTC+3, ο χρήστης INADA Naoki > έγραψε: >> Read my mail again. >> >> > This error came from MySQL. If there are no logs in error_log, it's >> > your configuration issue. >> >> > See https://dev.mysql

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread alister
On Sun, 26 Mar 2017 07:43:51 -0700, Νίκος Βέργος wrote: > Τη Κυριακή, 26 Μαρτίου 2017 - 5:38:57 μ.μ. UTC+3, ο χρήστης alister > έγραψε: >> On Sun, 26 Mar 2017 07:24:49 -0700, Νίκος Βέργος wrote: >> >> > Τη Κυριακή, 26 Μαρτίου 2017 - 5:19:27 μ.μ. UTC+3, ο χρήστης Ian >> > έγραψε: >> > >> >> You n

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread Νίκος Βέργος
Τη Κυριακή, 26 Μαρτίου 2017 - 8:06:07 μ.μ. UTC+3, ο χρήστης INADA Naoki έγραψε: > Read my mail again. > > > This error came from MySQL. If there are no logs in error_log, it's > > your configuration issue. > > > See https://dev.mysql.com/doc/refman/5.7/en/update.html for Update > > statement syn

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread Νίκος Βέργος
I do not see why my UPDATE fails. cur.execute('''UPDATE visitors SET (pagesID, host, ref, location, useros, browser, visits) VALUES (%s, %s, %s, %s, %s, %s, %s)''') works i dont have to update table set column1 = this value, column2=that value and so on It's just when the LIKE clause jumps in th

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread INADA Naoki
Read my mail again. > This error came from MySQL. If there are no logs in error_log, it's > your configuration issue. > See https://dev.mysql.com/doc/refman/5.7/en/update.html for Update > statement syntax. -- https://mail.python.org/mailman/listinfo/python-list

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread Νίκος Βέργος
Any ideas on how to make progress on that? After all its just an UPDATE with a WHERE clause?! Do you also think is DBI related issue? -- https://mail.python.org/mailman/listinfo/python-list

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread Joel Goldstick
On Sun, Mar 26, 2017 at 11:48 AM, Νίκος Βέργος wrote: > Τη Κυριακή, 26 Μαρτίου 2017 - 6:39:01 μ.μ. UTC+3, ο χρήστης Steve D'Aprano > έγραψε: >> On Mon, 27 Mar 2017 02:11 am, Νίκος Βέργος wrote: >> >> > I just tried: >> > >> > domain = '.'.join( host.split('.')[-2:] ) >> > domain = '%' + domain +

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread Νίκος Βέργος
Currently to avoid any misinformations my code looks as follows: domain = '.'.join( host.split('.')[-2:] ) domain_query = '%%%s' % domain cur.execute('''UPDATE visitors SET (pagesID, host, ref, location, useros, browser, visits) VALUES (%s, %s, %s, %s, %s, %s, %s) WHERE host LIKE %s''', (pID, d

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread Chris Angelico
On Mon, Mar 27, 2017 at 2:48 AM, Νίκος Βέργος wrote: >> > which you can see at http://superhost.gr >> >> Ah, Nikos, its been a long time! I thought I recognised your style of >> posting. > > > Howdy Steve! > Yes its me and yes its have been a long time! How are you?! > Irony lost. ChrisA -- htt

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread Νίκος Βέργος
Τη Κυριακή, 26 Μαρτίου 2017 - 6:39:01 μ.μ. UTC+3, ο χρήστης Steve D'Aprano έγραψε: > On Mon, 27 Mar 2017 02:11 am, Νίκος Βέργος wrote: > > > I just tried: > > > > domain = '.'.join( host.split('.')[-2:] ) > > domain = '%' + domain + '%' > > > > cur.execute('''UPDATE visitors SET (pagesID, host,

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread Νίκος Βέργος
Τη Κυριακή, 26 Μαρτίου 2017 - 6:28:12 μ.μ. UTC+3, ο χρήστης Chris Angelico έγραψε: > On Mon, Mar 27, 2017 at 2:11 AM, Νίκος Βέργος wrote: > > Τη Κυριακή, 26 Μαρτίου 2017 - 5:49:00 μ.μ. UTC+3, ο χρήστης Ian έγραψε: > > > >> The database wrapper won't do substitution into the middle of a string > >

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread Steve D'Aprano
On Mon, 27 Mar 2017 02:11 am, Νίκος Βέργος wrote: > I just tried: > > domain = '.'.join( host.split('.')[-2:] ) > domain = '%' + domain + '%' > > cur.execute('''UPDATE visitors SET (pagesID, host, ref, location, useros, > browser, visits) VALUES (%s, %s, %s, %s, %s, %s, %s) WHERE host LIKE "%s"

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread Chris Angelico
On Mon, Mar 27, 2017 at 2:11 AM, Νίκος Βέργος wrote: > Τη Κυριακή, 26 Μαρτίου 2017 - 5:49:00 μ.μ. UTC+3, ο χρήστης Ian έγραψε: > >> The database wrapper won't do substitution into the middle of a string >> like that. Either concatenate the literal %'s on in the SQL statement >> or add them to the

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread Νίκος Βέργος
domain = '.'.join( host.split('.')[-2:] ) domain = '%' + domain + '%' domain = '%%%s%%' % domain domain = '%{}%'.format(domain) cur.execute('''UPDATE visitors SET (pagesID, host, ref, location, useros, browser, visits) VALUES (%s, %s, %s, %s, %s, %s, %s) WHERE host LIKE "%s" ''',

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread Νίκος Βέργος
Τη Κυριακή, 26 Μαρτίου 2017 - 5:49:00 μ.μ. UTC+3, ο χρήστης Ian έγραψε: > The database wrapper won't do substitution into the middle of a string > like that. Either concatenate the literal %'s on in the SQL statement > or add them to the string before you pass it in, i.e. '%' + domain + > '%' or '

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread Ian Kelly
On Sun, Mar 26, 2017 at 8:24 AM, Νίκος Βέργος wrote: > Τη Κυριακή, 26 Μαρτίου 2017 - 5:19:27 μ.μ. UTC+3, ο χρήστης Ian έγραψε: > >> You need to change the placeholders back. The poster who told you to >> replace them was misinformed. > > okey altered them back to > > cur.execute('''UPDATE visitors

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread Νίκος Βέργος
I see thank you for pointing that out. Now i'm receiving no error in error_log but when i'm running the script it displays this: ProgrammingError(1064, "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '(pages

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread Steve D'Aprano
On Mon, 27 Mar 2017 12:52 am, Νίκος Βέργος wrote: > cur.execute('''UPDATE visitors SET (pagesID, host, ref, location, useros, > browser, visits) VALUES ({}, {}, {}, {}, {}, {}, {}) WHERE host LIKE > "{}"'''.format(pID, domain, ref, location, useros, browser, lastvisit, > domain) ) > > Same kind o

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread Νίκος Βέργος
i have tried that 2 days ago. Problem is that you maintained space before and after '%s' which wont work within like How would you type it without space as in "%%s%" ? Στις Κυρ, 26 Μαρ 2017 στις 5:32 μ.μ., ο/η INADA Naoki < songofaca...@gmail.com> έγραψε: > > I MEAN HOW TO DIFFERENTIATE '%S' F

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread Steve D'Aprano
On Mon, 27 Mar 2017 01:24 am, Νίκος Βέργος wrote: > I MEAN HOW TO DIFFERENTIATE '%S' FROM LITERAL '%' character. Use %% for a literal percent character. py> '%s %% %s' % ('hello', 'world') 'hello % world' -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure en

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread Νίκος Βέργος
Τη Κυριακή, 26 Μαρτίου 2017 - 5:38:57 μ.μ. UTC+3, ο χρήστης alister έγραψε: > On Sun, 26 Mar 2017 07:24:49 -0700, Νίκος Βέργος wrote: > > > Τη Κυριακή, 26 Μαρτίου 2017 - 5:19:27 μ.μ. UTC+3, ο χρήστης Ian έγραψε: > > > >> You need to change the placeholders back. The poster who told you to > >> re

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread alister
On Sun, 26 Mar 2017 07:24:49 -0700, Νίκος Βέργος wrote: > Τη Κυριακή, 26 Μαρτίου 2017 - 5:19:27 μ.μ. UTC+3, ο χρήστης Ian έγραψε: > >> You need to change the placeholders back. The poster who told you to >> replace them was misinformed. > > okey altered them back to > > cur.execute('''UPDATE vi

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread INADA Naoki
I used space only for readability. It's not required. >>> '%%%s%%' % (42,) '%42%' On Sun, Mar 26, 2017 at 11:35 PM, Νίκος Βέργος wrote: > i have tried that 2 days ago. > > Problem is that you maintained space before and after '%s' which wont work > within like > > How would you type it without

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread INADA Naoki
> I MEAN HOW TO DIFFERENTIATE '%S' FROM LITERAL '%' character. > >>> '%% %s %%s' % (42,) '% 42 %s' Use %% -- https://mail.python.org/mailman/listinfo/python-list

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread Νίκος Βέργος
Τη Κυριακή, 26 Μαρτίου 2017 - 5:19:27 μ.μ. UTC+3, ο χρήστης Ian έγραψε: > You need to change the placeholders back. The poster who told you to > replace them was misinformed. okey altered them back to cur.execute('''UPDATE visitors SET (pagesID, host, ref, location, useros, browser, visits) VAL

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread Ian Kelly
On Sun, Mar 26, 2017 at 8:07 AM, Νίκος Βέργος wrote: > Τη Κυριακή, 26 Μαρτίου 2017 - 5:04:27 μ.μ. UTC+3, ο χρήστης INADA Naoki This > error came from MySQL. If there are no logs in error_log, it's >> your configuration issue. >> >> See https://dev.mysql.com/doc/refman/5.7/en/update.html for Upda

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread Ian Kelly
On Sun, Mar 26, 2017 at 7:39 AM, MeV wrote: > On Sunday, March 26, 2017 at 6:34:30 AM UTC-7, Νίκος Βέργος wrote: >> with import cgitb; cgitb.enable() >> >> ProgrammingError(1064, "You have an error in your SQL syntax; check the >> manual that corresponds to your MariaDB server version for the rig

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread Νίκος Βέργος
Τη Κυριακή, 26 Μαρτίου 2017 - 5:04:27 μ.μ. UTC+3, ο χρήστης INADA Naoki This error came from MySQL. If there are no logs in error_log, it's > your configuration issue. > > See https://dev.mysql.com/doc/refman/5.7/en/update.html for Update > statement syntax. cur.execute('''UPDATE visitors SET (

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread Frank Millman
, domain, ref, location, useros, browser, lastvisit, domain) ) As if i have a syntactical error in someplace which i'am faling to see or PyMySQL wants special treatment regarding escaping special characters. I don't know MySQL, but for most RDBMS's, the construction you sh

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread INADA Naoki
On Sun, Mar 26, 2017 at 10:34 PM, Νίκος Βέργος wrote: > with import cgitb; cgitb.enable() > > ProgrammingError(1064, "You have an error in your SQL syntax; check the > manual that corresponds to your MariaDB server version for the right syntax > to use near '(pagesID, host, ref, location, useros

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread Νίκος Βέργος
cur.execute('''UPDATE visitors SET (pagesID, host, ref, location, useros, browser, visits) VALUES ({}, {}, {}, {}, {}, {}, {}) WHERE host LIKE "{}"'''.format(pID, domain, ref, location, useros, browser, lastvisit, domain) ) Same kind of output in the error-log even with this attempt. -- https:/

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread Νίκος Βέργος
Τη Κυριακή, 26 Μαρτίου 2017 - 4:39:44 μ.μ. UTC+3, ο χρήστης MeV έγραψε: > On Sunday, March 26, 2017 at 6:34:30 AM UTC-7, Νίκος Βέργος wrote: > > with import cgitb; cgitb.enable() > > > > ProgrammingError(1064, "You have an error in your SQL syntax; check the > > manual that corresponds to your Ma

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread Νίκος Βέργος
Τη Κυριακή, 26 Μαρτίου 2017 - 4:39:44 μ.μ. UTC+3, ο χρήστης MeV έγραψε: > On Sunday, March 26, 2017 at 6:34:30 AM UTC-7, Νίκος Βέργος wrote: > > with import cgitb; cgitb.enable() > > > > ProgrammingError(1064, "You have an error in your SQL syntax; check the > > manual that corresponds to your Ma

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread Νίκος Βέργος
, domain, ref, location, useros, browser, lastvisit, domain) ) if cur.rowcount(): botfound = True break [/code] As if i have a syntactical error in someplace which i'am faling to s

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread MeV
On Sunday, March 26, 2017 at 6:34:30 AM UTC-7, Νίκος Βέργος wrote: > with import cgitb; cgitb.enable() > > ProgrammingError(1064, "You have an error in your SQL syntax; check the > manual that corresponds to your MariaDB server version for the right syntax > to use near '(pagesID, host, ref, loc

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread Νίκος Βέργος
with import cgitb; cgitb.enable() ProgrammingError(1064, "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '(pagesID, host, ref, location, useros, browser, visits) VALUES (1, 'cyta.gr', '' at line 1") that i

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread Jussi Piitulainen
Νίκος Βέργος writes: > print('''UPDATE visitors SET (pagesID, host, ref, location, useros, > browser, visits) VALUES (%s, %s, %s, %s, %s, %s, %s) WHERE host LIKE > "%s"''', (pID, domain, ref, location, useros, browser, lastvisit, > domain) ) > > prints out: > > UPDATE visitors SET (pagesID, host,

Escaping confusion with Python 3 + MySQL

2017-03-26 Thread Νίκος Βέργος
print('''UPDATE visitors SET (pagesID, host, ref, location, useros, browser, visits) VALUES (%s, %s, %s, %s, %s, %s, %s) WHERE host LIKE "%s"''', (pID, domain, ref, location, useros, browser, lastvisit, domain) ) prints out: UPDATE visitors SET (pagesID, host, ref, location, useros, browser, vi

Escaping a Python sandbox

2013-03-17 Thread Steven D'Aprano
to get a traceback object are via the inspect or the sys modules which we can’t import. After being blocked on that problem, I went to work on other problems, slept a lot, and woke up to the solution I needed! http://blog.delroth.net/2013/03/escaping-a-python-sandbox-ndh-2013-quals-writeup

Re: Escaping list of numbers for Postgres column names

2013-02-23 Thread andydtaylor
In reply to my own question, postgres column names must begin with a letter or an underscore. So this is what I have done: >>> for row in cursor_from: ... if row[8]: ... stn_list_short.append("_" + row[0]) I can now use stn_list_short to create my columns -- http://mail.python.org/m

Escaping list of numbers for Postgres column names

2013-02-23 Thread andydtaylor
Hi I have some convenient short place name IDs which would be handy for column names. Unfortunately, many begin with a number. I can work around this by appending a letter to each one, but should I escape the number in such a way that I can use it directly as my column name, in the same way a

Re: Create xml with elementtree ET and xml escaping

2012-12-15 Thread Stefan Behnel
nenad.ci...@gmail.com, 12.12.2012 03:19: > Il giorno martedì 11 dicembre 2012 20:59:54 UTC+1, MRAB ha scritto: >> >>> Since I have also the need to sign the XML I need the ability to create xml >>> but without xml escaping (unescaped data are signed). >> >>

Re: Create xml with elementtree ET and xml escaping

2012-12-11 Thread nenad . cikic
attribute's value: > > > > OK I understood. > > > because it's also being used as a delimiter in that case, but elsewhere > > it has no special meaning. > > > > > Since I have also the need to sign the XML I need the ability

Re: Create xml with elementtree ET and xml escaping

2012-12-11 Thread MRAB
also the need to sign the XML I need the ability to create xml but without xml escaping (unescaped data are signed). XML with the escaping isn't valid XML. If i do ET.toString(root,'utf8',text') i do not get the xml tags and if I do ET.toString(root,'utf8') I

Create xml with elementtree ET and xml escaping

2012-12-11 Thread nenad . cikic
;& but not " and ' Is that normal? Since I have also the need to sign the XML I need the ability to create xml but without xml escaping (unescaped data are signed). If i do ET.toString(root,'utf8',text') i do not get the xml tags and if I do ET.toString(root,'ut

Escaping from the tedium of naive datetime objects.

2012-10-26 Thread Adam Tauno Williams
Yesterday I stumbled upon a nice solution to dealing with naive datetimes vs. localized datetimes, and much of the tedium that issues from that problem. Maybe this is very common knownledge but it wasn't mentioned in anything I've read - it really cleans up some opertaions.

Re: escaping/encoding/formatting in python

2012-05-23 Thread John Nagle
On 4/5/2012 10:10 PM, Steve Howell wrote: On Apr 5, 9:59 pm, rusi wrote: On Apr 6, 6:56 am, Steve Howell wrote: You've one-upped me with 2-to-the-N backspace escaping. Early attempts at UNIX word processing, "nroff" and "troff", suffered from that problem

Re: escaping/encoding/formatting in python

2012-05-21 Thread rusi
On Apr 6, 10:13 am, Steve Howell wrote: > On Apr 5, 9:59 pm,rusi wrote: > > > On Apr 6, 6:56 am,SteveHowell wrote: > > > > One of the biggest nuisances for programmers, just beneath date/time > > > APIs in the pantheon of annoyances, is that we are constantly dea

Re: escaping

2012-04-17 Thread Serhiy Storchaka
This was the original intention, i.e. 'format' preferred over '%' but even the core developers have backtracked on this issue. If I could remember the thread it was on I'd give you a reference, but I haven't the faintest idea as to which mailing list it was on. I'm certain that other subscribers w

Re: escaping

2012-04-16 Thread Steven D'Aprano
On Mon, 16 Apr 2012 23:27:04 +, Steven D'Aprano wrote: > On Mon, 16 Apr 2012 23:12:52 +, Steven D'Aprano wrote: > >> But it does. Before making assumptions about what format does and does >> not offer, remember that the Fine Manual is your friend. > > Ha, it would help if I remembered to

Re: escaping

2012-04-16 Thread Mark Lawrence
On 16/04/2012 11:03, Kiuhnm wrote: I like this one. Since I read somewhere that 'format' is preferred over '%', I was focusing on 'format' and I didn't think of '%'. Anyway, it's odd that 'format' doesn't offer something similar. Kiuhnm This was the original intention, i.e. 'format' preferred

Re: escaping

2012-04-16 Thread Steven D'Aprano
On Mon, 16 Apr 2012 23:12:52 +, Steven D'Aprano wrote: > But it does. Before making assumptions about what format does and does > not offer, remember that the Fine Manual is your friend. Ha, it would help if I remembered to link to the manual... sorry about that. http://docs.python.org/libr

Re: escaping

2012-04-16 Thread Steven D'Aprano
On Mon, 16 Apr 2012 12:03:31 +0200, Kiuhnm wrote: > On 4/16/2012 4:42, Steven D'Aprano wrote: >> On Sun, 15 Apr 2012 23:07:36 +0200, Kiuhnm wrote: >> >>> This is the behavior I need: >>> path = path.replace('\\', '') >>> msg = ". {} .. '{}' .. {} .".format(a, path, b) >>> Is there

Re: escaping

2012-04-16 Thread Kiuhnm
On 4/16/2012 17:14, Jon Clements wrote: On Monday, 16 April 2012 11:03:31 UTC+1, Kiuhnm wrote: On 4/16/2012 4:42, Steven D'Aprano wrote: On Sun, 15 Apr 2012 23:07:36 +0200, Kiuhnm wrote: This is the behavior I need: path = path.replace('\\', '') msg = ". {} .. '{}' .. {} ."

Re: escaping

2012-04-16 Thread Jon Clements
On Monday, 16 April 2012 11:03:31 UTC+1, Kiuhnm wrote: > On 4/16/2012 4:42, Steven D'Aprano wrote: > > On Sun, 15 Apr 2012 23:07:36 +0200, Kiuhnm wrote: > > > >> This is the behavior I need: > >> path = path.replace('\\', '') > >> msg = ". {} .. '{}' .. {} .".format(a, path, b) > >

Re: escaping

2012-04-16 Thread Serhiy Storchaka
16.04.12 00:07, Kiuhnm написав(ла): path = path.replace('\\', '') If you think that it is too complicated: path = re.sub('', '', path) -- http://mail.python.org/mailman/listinfo/python-list

Re: escaping

2012-04-16 Thread Kiuhnm
On 4/16/2012 12:03, Kiuhnm wrote: On 4/16/2012 4:42, Steven D'Aprano wrote: On Sun, 15 Apr 2012 23:07:36 +0200, Kiuhnm wrote: This is the behavior I need: path = path.replace('\\', '') msg = ". {} .. '{}' .. {} .".format(a, path, b) Is there a better way? This works for me: a = "spam"

Re: escaping

2012-04-16 Thread Peter Otten
Kiuhnm wrote: > On 4/16/2012 4:42, Steven D'Aprano wrote: >> On Sun, 15 Apr 2012 23:07:36 +0200, Kiuhnm wrote: >> >>> This is the behavior I need: >>> path = path.replace('\\', '') >>> msg = ". {} .. '{}' .. {} .".format(a, path, b) >>> Is there a better way? >> >> >> This works fo

Re: escaping

2012-04-16 Thread Kiuhnm
On 4/16/2012 4:42, Steven D'Aprano wrote: On Sun, 15 Apr 2012 23:07:36 +0200, Kiuhnm wrote: This is the behavior I need: path = path.replace('\\', '') msg = ". {} .. '{}' .. {} .".format(a, path, b) Is there a better way? This works for me: a = "spam" b = "ham" path = r"C:\

Re: escaping

2012-04-15 Thread Steven D'Aprano
On Sun, 15 Apr 2012 23:07:36 +0200, Kiuhnm wrote: > This is the behavior I need: > path = path.replace('\\', '') > msg = ". {} .. '{}' .. {} .".format(a, path, b) > Is there a better way? This works for me: >>> a = "spam" >>> b = "ham" >>> path = r"C:\a\b\c\d\e.txt" >>> msg = ". %

Re: escaping

2012-04-15 Thread Terry Reedy
On 4/15/2012 5:07 PM, Kiuhnm wrote: This is the behavior I need: path = path.replace('\\', '') Is there a better way? For one-time use, and given that you cannot un-double with the r prefix, not that I know of. For using the substrings multiple times, name them. >>> s = r'abc\cd\ef' >>>

Re: escaping

2012-04-15 Thread Steve Howell
hpick idiom predates Python. It's a little hard on the fingers and eyes at first, but it's pretty expressive--most people will clearly see that you are dealing with escaping issues. If you are just printing a message to the log, consider repr(). -- http://mail.python.org/mailman/listinfo/python-list

escaping

2012-04-15 Thread Kiuhnm
This is the behavior I need: path = path.replace('\\', '') msg = ". {} .. '{}' .. {} .".format(a, path, b) Is there a better way? Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list

Re: escaping/encoding/formatting in python

2012-04-07 Thread Chris Angelico
On Sat, Apr 7, 2012 at 3:36 PM, Nobody wrote: > The delimiter can be chosen either by analysing the string > or by choosing something a string at random and relying upon a collision > being statistically improbable. The same techniques being available to MIME multi-part encoders, and for the same

Re: escaping/encoding/formatting in python

2012-04-06 Thread Nobody
On Fri, 06 Apr 2012 06:22:13 -0700, rusi wrote: > But are not such cases rare? They exist, therefore they have to be supported somehow. > For example code such as: > print '"' > print str(something) > print '"' > > could better be written as > print '"%s"' % str(something) Not if the text betw

  1   2   3   4   >