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, visits) 
VALUES (%s, %s, %s, %s, %s, %s, %s) WHERE host LIKE "%s" (1, 'cyta.gr', 'Άμεση 
Πρόσβαση', 'Greece', 'Windows', 'Chrome', '17-03-24 22:04:24', 'cyta.gr')

How should i write the cursor.execute in order to be parsed properly?
As i have it now %s does not get substituted.
i use PyMySQL by the way and i have tried every possible combination even with 
% instead of a comma but still produces errors.
-- 
https://mail.python.org/mailman/listinfo/python-list


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, ref, location, useros, browser,
> visits) VALUES (%s, %s, %s, %s, %s, %s, %s) WHERE host LIKE "%s" (1,
> 'cyta.gr', 'Άμεση Πρόσβαση', 'Greece', 'Windows', 'Chrome', '17-03-24
> 22:04:24', 'cyta.gr')
>
> How should i write the cursor.execute in order to be parsed properly?
> As i have it now %s does not get substituted.
> i use PyMySQL by the way and i have tried every possible combination
> even with % instead of a comma but still produces errors.

You should include the actual statement that produces the errors, not a
very different statement. And you should include the actual text of the
error messages.

To learn about PyMySQL cursor.execute, put "pymysql cursor execute"
(without the quotes) to a search engine and find something like the
following document (the first hit from google.fi for me).

https://dev.mysql.com/doc/connector-python/en/connector-python-api-mysqlcursor-execute.html

That looks helpful to me.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python question

2017-03-26 Thread Steve D'Aprano
On Sun, 26 Mar 2017 01:55 pm, c...@zip.com.au wrote:

> 1: He BCCed the list, not us individually. Look at the headers.

BCCed addresses aren't visible in the headers. That's why they're BLIND CC.
The lack of personal email addresses in the headers doesn't prove they
weren't there. All the headers tell us is that he definitely posted to the
list. (But we knew that!)

Your interpretation doesn't explain why I received a copy sent to my
personal email address. I read this via the newsgroup comp.lang.python, not
the mailing list, and I'm not subscribed to the email mailing list. If the
OP had merely BCCed the mailing list, I wouldn't have received a copy in my
personal inbox.



-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: why and how to run forever and debug when error in for proc in psutil.process_iter()?

2017-03-26 Thread Ho Yeung Lee
On Sunday, March 26, 2017 at 10:33:51 AM UTC+8, Deborah Swanson wrote:
> Someone here can probably help you, but they'll need your Python
> version, operating system, and full traceback. They get tired of saying
> so. 
> 
> In this case, the full traceback is needed to see what went wrong and
> when (after which statements).
> 
> 
> Ho Yeung Lee wrote, on Saturday, March 25, 2017 1:38 AM
> > 
> > expect below to run forever and keep running a fixed number 
> > of thread in python
> > 
> > would like to kill tasks when process connect internet except 
> > chrome and explorer.exe
> > 
> > i do this because MalwareBytes can not disconnect these 
> > existing trojan when my notebook connect internet
> > 
> > after run a few minutes, the program stopped, but i have 
> > already kept create process, why the whole program end?
> > 
> > why and how to debug when error in for proc in psutil.process_iter()?
> > 
> > 
> > import os
> > import psutil
> > import multiprocessing
> > import time
> > import sys
> > 
> > def cleantask():
> > p = os.popen("netstat -ano")
> > while 1:
> > line = p.readline()
> > if "TCP" in line or "UDP" in line:
> > linelist = line.split()
> > if len(linelist) > 4:
> > if "LISTEN" in str(linelist[3]):
> > for proc in psutil.process_iter():
> > try:
> > if "pop" not in str(proc.name).tolower():
> > os.system("taskkill /f /pid 
> > "+str(proc._pid))
> > except:
> > dummy = 1
> > #print "Unexpected error:", 
> > sys.exc_info()[0]
> > #print "Unexpected error:", 
> > sys.exc_info()[1]
> > if "ESTABLISHED" in str(linelist[3]):
> > if "127.0.0.1" not in str(linelist[2]):
> > for proc in psutil.process_iter():
> > try:
> > if str(linelist[4]) in 
> > str(proc._pid):
> > 
> > print(str(linelist[2])+","+str(linelist[4])+","+proc.name)
> > if "111.221" not in 
> > str(linelist[2]) and "explorer.exe" not in str(proc.name).tolower():
> > os.system("taskkill /f 
> > /pid "+str(proc._pid))
> > except:
> > dummy = 1
> > #print "Unexpected error:", 
> > sys.exc_info()[0]
> > #print "Unexpected error:", 
> > sys.exc_info()[1]
> > print(line)
> > if not line: break
> > 
> > if __name__ == '__main__':
> > print("main")
> > try:
> > numberofrunning = 0
> > plist = []
> > for ii in range(0,5):  
> > p = multiprocessing.Process(target=cleantask(), args=(0,))
> > p.start()
> > plist.append(p)
> > numberofrunning = numberofrunning + 1
> > time.sleep(1)
> > for pp in plist:
> > pp.join()
> > if pp.is_alive() == False:
> > numberofrunning = numberofrunning - 1
> > plist.remove(pp)
> > if numberofrunning > 10:
> > print "more than 10 process"
> > else:
> > print("number of process = " + str(numberofrunning))
> > if numberofrunning <= 5:
> > p = 
> > multiprocessing.Process(target=cleantask(), args=(0,))
> > p.start()
> > plist.append(p)
> > numberofrunning = numberofrunning + 1
> > time.sleep(1)
> > except:
> > print "Unexpected error:", sys.exc_info()[0]
> > print "Unexpected error:", sys.exc_info()[1]
> > -- 
> > https://mail.python.org/mailman/listinfo/python-list
> >

after window update error, I can not login window and reset system and
reinstall every thing

python 2.7.12

there is no error when run, but it end after running a few minutes
if commend the forever loop in main

import os
import psutil
import multiprocessing
import time
import sys

def cleantask():
bufsize = 0
f = open("d:\\killlist.txt",'a',bufsize)
p = os.popen("netstat -ano")
while 1:
line = p.readline()
if "TCP" in line or "UDP" in line:
linelist = line.split()
if len(linelist) > 4:
if "LISTEN" in str(linelist[3]):
for proc in psutil.process_iter():
try:
if "pop" in str(proc.name).lower():
os.system("taskkill /f /pid "+str(proc._pid))
#print("here8")

print(str(linelist[2])+","+str(linelist[4])+","+proc.name 

Re: why and how to run forever and debug when error in for proc in psutil.process_iter()?

2017-03-26 Thread Ho Yeung Lee
On Sunday, March 26, 2017 at 7:32:12 PM UTC+8, Ho Yeung Lee wrote:
> On Sunday, March 26, 2017 at 10:33:51 AM UTC+8, Deborah Swanson wrote:
> > Someone here can probably help you, but they'll need your Python
> > version, operating system, and full traceback. They get tired of saying
> > so. 
> > 
> > In this case, the full traceback is needed to see what went wrong and
> > when (after which statements).
> > 
> > 
> > Ho Yeung Lee wrote, on Saturday, March 25, 2017 1:38 AM
> > > 
> > > expect below to run forever and keep running a fixed number 
> > > of thread in python
> > > 
> > > would like to kill tasks when process connect internet except 
> > > chrome and explorer.exe
> > > 
> > > i do this because MalwareBytes can not disconnect these 
> > > existing trojan when my notebook connect internet
> > > 
> > > after run a few minutes, the program stopped, but i have 
> > > already kept create process, why the whole program end?
> > > 
> > > why and how to debug when error in for proc in psutil.process_iter()?
> > > 
> > > 
> > > import os
> > > import psutil
> > > import multiprocessing
> > > import time
> > > import sys
> > > 
> > > def cleantask():
> > > p = os.popen("netstat -ano")
> > > while 1:
> > > line = p.readline()
> > > if "TCP" in line or "UDP" in line:
> > > linelist = line.split()
> > > if len(linelist) > 4:
> > > if "LISTEN" in str(linelist[3]):
> > > for proc in psutil.process_iter():
> > > try:
> > > if "pop" not in str(proc.name).tolower():
> > > os.system("taskkill /f /pid 
> > > "+str(proc._pid))
> > > except:
> > > dummy = 1
> > > #print "Unexpected error:", 
> > > sys.exc_info()[0]
> > > #print "Unexpected error:", 
> > > sys.exc_info()[1]
> > > if "ESTABLISHED" in str(linelist[3]):
> > > if "127.0.0.1" not in str(linelist[2]):
> > > for proc in psutil.process_iter():
> > > try:
> > > if str(linelist[4]) in 
> > > str(proc._pid):
> > > 
> > > print(str(linelist[2])+","+str(linelist[4])+","+proc.name)
> > > if "111.221" not in 
> > > str(linelist[2]) and "explorer.exe" not in str(proc.name).tolower():
> > > os.system("taskkill /f 
> > > /pid "+str(proc._pid))
> > > except:
> > > dummy = 1
> > > #print "Unexpected error:", 
> > > sys.exc_info()[0]
> > > #print "Unexpected error:", 
> > > sys.exc_info()[1]
> > > print(line)
> > > if not line: break
> > > 
> > > if __name__ == '__main__':
> > > print("main")
> > > try:
> > > numberofrunning = 0
> > > plist = []
> > > for ii in range(0,5):  
> > > p = multiprocessing.Process(target=cleantask(), args=(0,))
> > > p.start()
> > > plist.append(p)
> > > numberofrunning = numberofrunning + 1
> > > time.sleep(1)
> > > for pp in plist:
> > > pp.join()
> > >   if pp.is_alive() == False:
> > > numberofrunning = numberofrunning - 1
> > > plist.remove(pp)
> > > if numberofrunning > 10:
> > > print "more than 10 process"
> > > else:
> > > print("number of process = " + str(numberofrunning))
> > > if numberofrunning <= 5:
> > > p = 
> > > multiprocessing.Process(target=cleantask(), args=(0,))
> > > p.start()
> > > plist.append(p)
> > > numberofrunning = numberofrunning + 1
> > > time.sleep(1)
> > > except:
> > > print "Unexpected error:", sys.exc_info()[0]
> > > print "Unexpected error:", sys.exc_info()[1]
> > > -- 
> > > https://mail.python.org/mailman/listinfo/python-list
> > >
> 
> after window update error, I can not login window and reset system and
> reinstall every thing
> 
> python 2.7.12
> 
> there is no error when run, but it end after running a few minutes
> if commend the forever loop in main
> 
> import os
> import psutil
> import multiprocessing
> import time
> import sys
> 
> def cleantask():
> bufsize = 0
> f = open("d:\\killlist.txt",'a',bufsize)
> p = os.popen("netstat -ano")
> while 1:
> line = p.readline()
> if "TCP" in line or "UDP" in line:
> linelist = line.split()
> if len(linelist) > 4:
> if "LISTEN" in str(linelist[3]):
> for proc in psutil

Re: why and how to run forever and debug when error in for proc in psutil.process_iter()?

2017-03-26 Thread Ho Yeung Lee
On Sunday, March 26, 2017 at 7:40:20 PM UTC+8, Ho Yeung Lee wrote:
> On Sunday, March 26, 2017 at 7:32:12 PM UTC+8, Ho Yeung Lee wrote:
> > On Sunday, March 26, 2017 at 10:33:51 AM UTC+8, Deborah Swanson wrote:
> > > Someone here can probably help you, but they'll need your Python
> > > version, operating system, and full traceback. They get tired of saying
> > > so. 
> > > 
> > > In this case, the full traceback is needed to see what went wrong and
> > > when (after which statements).
> > > 
> > > 
> > > Ho Yeung Lee wrote, on Saturday, March 25, 2017 1:38 AM
> > > > 
> > > > expect below to run forever and keep running a fixed number 
> > > > of thread in python
> > > > 
> > > > would like to kill tasks when process connect internet except 
> > > > chrome and explorer.exe
> > > > 
> > > > i do this because MalwareBytes can not disconnect these 
> > > > existing trojan when my notebook connect internet
> > > > 
> > > > after run a few minutes, the program stopped, but i have 
> > > > already kept create process, why the whole program end?
> > > > 
> > > > why and how to debug when error in for proc in psutil.process_iter()?
> > > > 
> > > > 
> > > > import os
> > > > import psutil
> > > > import multiprocessing
> > > > import time
> > > > import sys
> > > > 
> > > > def cleantask():
> > > > p = os.popen("netstat -ano")
> > > > while 1:
> > > > line = p.readline()
> > > > if "TCP" in line or "UDP" in line:
> > > > linelist = line.split()
> > > > if len(linelist) > 4:
> > > > if "LISTEN" in str(linelist[3]):
> > > > for proc in psutil.process_iter():
> > > > try:
> > > > if "pop" not in str(proc.name).tolower():
> > > > os.system("taskkill /f /pid 
> > > > "+str(proc._pid))
> > > > except:
> > > > dummy = 1
> > > > #print "Unexpected error:", 
> > > > sys.exc_info()[0]
> > > > #print "Unexpected error:", 
> > > > sys.exc_info()[1]
> > > > if "ESTABLISHED" in str(linelist[3]):
> > > > if "127.0.0.1" not in str(linelist[2]):
> > > > for proc in psutil.process_iter():
> > > > try:
> > > > if str(linelist[4]) in 
> > > > str(proc._pid):
> > > > 
> > > > print(str(linelist[2])+","+str(linelist[4])+","+proc.name)
> > > > if "111.221" not in 
> > > > str(linelist[2]) and "explorer.exe" not in str(proc.name).tolower():
> > > > os.system("taskkill /f 
> > > > /pid "+str(proc._pid))
> > > > except:
> > > > dummy = 1
> > > > #print "Unexpected error:", 
> > > > sys.exc_info()[0]
> > > > #print "Unexpected error:", 
> > > > sys.exc_info()[1]
> > > > print(line)
> > > > if not line: break
> > > > 
> > > > if __name__ == '__main__':
> > > > print("main")
> > > > try:
> > > > numberofrunning = 0
> > > > plist = []
> > > > for ii in range(0,5):  
> > > > p = multiprocessing.Process(target=cleantask(), args=(0,))
> > > > p.start()
> > > > plist.append(p)
> > > > numberofrunning = numberofrunning + 1
> > > > time.sleep(1)
> > > > for pp in plist:
> > > > pp.join()
> > > > if pp.is_alive() == False:
> > > > numberofrunning = numberofrunning - 1
> > > > plist.remove(pp)
> > > > if numberofrunning > 10:
> > > > print "more than 10 process"
> > > > else:
> > > > print("number of process = " + str(numberofrunning))
> > > > if numberofrunning <= 5:
> > > > p = 
> > > > multiprocessing.Process(target=cleantask(), args=(0,))
> > > > p.start()
> > > > plist.append(p)
> > > > numberofrunning = numberofrunning + 1
> > > > time.sleep(1)
> > > > except:
> > > > print "Unexpected error:", sys.exc_info()[0]
> > > > print "Unexpected error:", sys.exc_info()[1]
> > > > -- 
> > > > https://mail.python.org/mailman/listinfo/python-list
> > > >
> > 
> > after window update error, I can not login window and reset system and
> > reinstall every thing
> > 
> > python 2.7.12
> > 
> > there is no error when run, but it end after running a few minutes
> > if commend the forever loop in main
> > 
> > import os
> > import psutil
> > import multiprocessing
> > import time
> > import sys
> > 
> > def cleantask():
> > bufsize = 0
> > f = open("d:\\kill

Re: Python question

2017-03-26 Thread Cameron Simpson

On 26Mar2017 20:55, Steve D'Aprano  wrote:

On Sun, 26 Mar 2017 01:55 pm, c...@zip.com.au wrote:

1: He BCCed the list, not us individually. Look at the headers.


BCCed addresses aren't visible in the headers. That's why they're BLIND CC.


Of course, but the received headers etc show it passed though the list.


The lack of personal email addresses in the headers doesn't prove they
weren't there. All the headers tell us is that he definitely posted to the
list. (But we knew that!)


If the headers say it went though the list, _that_ copy went through the list, 
_not_ to your personal address (well, not from him; of course the list 
delivered it to you).



Your interpretation doesn't explain why I received a copy sent to my
personal email address. I read this via the newsgroup comp.lang.python, not
the mailing list, and I'm not subscribed to the email mailing list. If the
OP had merely BCCed the mailing list, I wouldn't have received a copy in my
personal inbox.


Fair point. Though I thought I only got one copy, might be wrong.

Cheers,
Cameron Simpson 
--
https://mail.python.org/mailman/listinfo/python-list


Re: Who are the "spacists"?

2017-03-26 Thread Mikhail V
On 26 March 2017 at 06:16, Wildman via Python-list
 wrote:
> On Tue, 21 Mar 2017 15:15:14 +0100, Mikhail V wrote:
>
>> And on linux console, by default one does not even have good
>> possibilities for text-mode pseudographics, it was more relevant
>> in DOS where one had rich possibilities and programmable
>> binary fonts.
>>
>> Mikhail
>
> Nonsense.

Why? IIRC I can do good pseudographics on linux only with extended
unicode character sets, so yes it is possible, is that what you mean?
-- 
https://mail.python.org/mailman/listinfo/python-list


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 is all i get form error. error_log doesnt produce errors when iam trying

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, domain, ref, location, useros, 
browser, lastvisit, domain) )

WHY the valued aren't getting substituted wi the aeguments i give it in to work 
with?
-- 
https://mail.python.org/mailman/listinfo/python-list


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, location, useros, browser, visits) VALUES 
> (1, 'cyta.gr', '' at line 1")
> 
> that is all i get form error. error_log doesnt produce errors when iam trying
> 
> 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, domain, ref, location, 
> useros, browser, lastvisit, domain) )
> 
> WHY the valued aren't getting substituted wi the aeguments i give it in to 
> work with?

The % construct is Python 2 and no longer supported in Python 3. You should 
read up on the "{}" and format method.

https://docs.python.org/3/tutorial/inputoutput.html#fancier-output-formatting
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread Νίκος Βέργος
Ths is the whole snippert i'am trying so you can see what i'm tryong to do.

[code]
# if bot is contained in hostname update all previous database 
bot hostname entries with current bot hostname
for bot in bots:
if bot in host:
domain = '.'.join( host.split('.')[-2:] )

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, 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 see or 
PyMySQL wants special treatment regarding escaping special characters.
-- 
https://mail.python.org/mailman/listinfo/python-list


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 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 is all i get form error. error_log doesnt produce errors when iam 
> > trying
> > 
> > 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, domain, ref, 
> > location, useros, browser, lastvisit, domain) )
> > 
> > WHY the valued aren't getting substituted wi the aeguments i give it in to 
> > work with?
> 
> The % construct is Python 2 and no longer supported in Python 3. You should 
> read up on the "{}" and format method.
> 
> https://docs.python.org/3/tutorial/inputoutput.html#fancier-output-formatting

Even with '{}' instead of '%s' iam still receiving similar errors.
And lathough iam using '%s' up until now substituting worked okey.

its htis where LIKE clause that is only failing.
-- 
https://mail.python.org/mailman/listinfo/python-list


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 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 is all i get form error. error_log doesnt produce errors when iam 
> > trying
> > 
> > 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, domain, ref, 
> > location, useros, browser, lastvisit, domain) )
> > 
> > WHY the valued aren't getting substituted wi the aeguments i give it in to 
> > work with?
> 
> The % construct is Python 2 and no longer supported in Python 3. You should 
> read up on the "{}" and format method.
> 
> https://docs.python.org/3/tutorial/inputoutput.html#fancier-output-formatting

[code]
cur.execute('''UPDATE visitors SET (pagesID, host, ref, location, useros, 
browser, visits) VALUES ({}, {}, {}, {}, {}, {}, {}) WHERE host LIKE "{}"''', 



(pID, domain, ref, location, useros, 
browser, lastvisit, domain) )
[/code]

now has the following response inside error_log

[code]
[Sun Mar 26 16:45:50.940077 2017] [cgi:error] [pid 2337] [client 
178.59.182.161:13755] AH01215: Error in sys.excepthook:
[Sun Mar 26 16:45:50.940126 2017] [cgi:error] [pid 2337] [client 
178.59.182.161:13755] AH01215: Traceback (most recent call last):
[Sun Mar 26 16:45:50.940151 2017] [cgi:error] [pid 2337] [client 
178.59.182.161:13755] AH01215:   File "/usr/local/lib/python3.5/cgitb.py", line 
268, in __call__
[Sun Mar 26 16:45:50.940166 2017] [cgi:error] [pid 2337] [client 
178.59.182.161:13755] AH01215: self.handle((etype, evalue, etb))
[Sun Mar 26 16:45:50.940189 2017] [cgi:error] [pid 2337] [client 
178.59.182.161:13755] AH01215:   File "/usr/local/lib/python3.5/cgitb.py", line 
273, in handle
[Sun Mar 26 16:45:50.940200 2017] [cgi:error] [pid 2337] [client 
178.59.182.161:13755] AH01215: self.file.write(reset())
[Sun Mar 26 16:45:50.940220 2017] [cgi:error] [pid 2337] [client 
178.59.182.161:13755] AH01215: ValueError: underlying buffer has been detached
[Sun Mar 26 16:45:50.940225 2017] [cgi:error] [pid 2337] [client 
178.59.182.161:13755] AH01215: 
[Sun Mar 26 16:45:50.940235 2017] [cgi:error] [pid 2337] [client 
178.59.182.161:13755] AH01215: Original exception was:
[Sun Mar 26 16:45:50.940249 2017] [cgi:error] [pid 2337] [client 
178.59.182.161:13755] AH01215: Traceback (most recent call last):
[Sun Mar 26 16:45:50.940265 2017] [cgi:error] [pid 2337] [client 
178.59.182.161:13755] AH01215:   File "metrites.py", line 355, in 
[Sun Mar 26 16:45:50.940298 2017] [cgi:error] [pid 2337] [client 
178.59.182.161:13755] AH01215: (pID, domain, ref, location, useros, 
browser, lastvisit, domain) )
[Sun Mar 26 16:45:50.940329 2017] [cgi:error] [pid 2337] [client 
178.59.182.161:13755] AH01215:   File 
"/usr/local/lib/python3.5/site-packages/pymysql/cursors.py", line 144, in 
execute
[Sun Mar 26 16:45:50.940343 2017] [cgi:error] [pid 2337] [client 
178.59.182.161:13755] AH01215: query = self.mogrify(query, args)
[Sun Mar 26 16:45:50.940379 2017] [cgi:error] [pid 2337] [client 
178.59.182.161:13755] AH01215:   File 
"/usr/local/lib/python3.5/site-packages/pymysql/cursors.py", line 135, in 
mogrify
[Sun Mar 26 16:45:50.940398 2017] [cgi:error] [pid 2337] [client 
178.59.182.161:13755] AH01215: query = query % self._escape_args(args, conn)
[Sun Mar 26 16:45:50.940420 2017] [cgi:error] [pid 2337] [client 
178.59.182.161:13755] AH01215: TypeError: not all arguments converted during 
string formatting
[/code]
-- 
https://mail.python.org/mailman/listinfo/python-list


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://mail.python.org/mailman/listinfo/python-list


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, browser, visits) VALUES 
> (1, 'cyta.gr', '' at line 1")
>
> that is all i get form error. error_log doesnt produce errors when iam trying
>

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 Frank Millman
"Νίκος Βέργος"  wrote in message 
news:8c5f0443-c61b-4059-8d6f-576152d59...@googlegroups.com...




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, 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 show only 
works for INSERT statements.


For UPDATE, you usually have to say -
   UPDATE {table} SET col_1 = val_1, col_2 = val_2 WHERE col_3 = val_3 ...

Frank Millman


--
https://mail.python.org/mailman/listinfo/python-list


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 (pagesID, host, ref, location, useros, 
browser, visits) VALUES ({}, {}, {}, {}, {}, {}, {}) WHERE host LIKE 
"%{}%"'''.format(pID, domain, ref, location, useros, browser, lastvisit, 
domain) ) 

output of error-log:

[code] 
[Sun Mar 26 16:45:50.940077 2017] [cgi:error] [pid 2337] [client 
178.59.182.161:13755] AH01215: Error in sys.excepthook: 
[Sun Mar 26 16:45:50.940126 2017] [cgi:error] [pid 2337] [client 
178.59.182.161:13755] AH01215: Traceback (most recent call last): 
[Sun Mar 26 16:45:50.940151 2017] [cgi:error] [pid 2337] [client 
178.59.182.161:13755] AH01215:   File "/usr/local/lib/python3.5/cgitb.py", line 
268, in __call__ 
[Sun Mar 26 16:45:50.940166 2017] [cgi:error] [pid 2337] [client 
178.59.182.161:13755] AH01215: self.handle((etype, evalue, etb)) 
[Sun Mar 26 16:45:50.940189 2017] [cgi:error] [pid 2337] [client 
178.59.182.161:13755] AH01215:   File "/usr/local/lib/python3.5/cgitb.py", line 
273, in handle 
[Sun Mar 26 16:45:50.940200 2017] [cgi:error] [pid 2337] [client 
178.59.182.161:13755] AH01215: self.file.write(reset()) 
[Sun Mar 26 16:45:50.940220 2017] [cgi:error] [pid 2337] [client 
178.59.182.161:13755] AH01215: ValueError: underlying buffer has been detached 
[Sun Mar 26 16:45:50.940225 2017] [cgi:error] [pid 2337] [client 
178.59.182.161:13755] AH01215: 
[Sun Mar 26 16:45:50.940235 2017] [cgi:error] [pid 2337] [client 
178.59.182.161:13755] AH01215: Original exception was: 
[Sun Mar 26 16:45:50.940249 2017] [cgi:error] [pid 2337] [client 
178.59.182.161:13755] AH01215: Traceback (most recent call last): 
[Sun Mar 26 16:45:50.940265 2017] [cgi:error] [pid 2337] [client 
178.59.182.161:13755] AH01215:   File "metrites.py", line 355, in  
[Sun Mar 26 16:45:50.940298 2017] [cgi:error] [pid 2337] [client 
178.59.182.161:13755] AH01215: (pID, domain, ref, location, useros, 
browser, lastvisit, domain) ) 
[Sun Mar 26 16:45:50.940329 2017] [cgi:error] [pid 2337] [client 
178.59.182.161:13755] AH01215:   File 
"/usr/local/lib/python3.5/site-packages/pymysql/cursors.py", line 144, in 
execute 
[Sun Mar 26 16:45:50.940343 2017] [cgi:error] [pid 2337] [client 
178.59.182.161:13755] AH01215: query = self.mogrify(query, args) 
[Sun Mar 26 16:45:50.940379 2017] [cgi:error] [pid 2337] [client 
178.59.182.161:13755] AH01215:   File 
"/usr/local/lib/python3.5/site-packages/pymysql/cursors.py", line 135, in 
mogrify 
[Sun Mar 26 16:45:50.940398 2017] [cgi:error] [pid 2337] [client 
178.59.182.161:13755] AH01215: query = query % self._escape_args(args, 
conn) 
[Sun Mar 26 16:45:50.940420 2017] [cgi:error] [pid 2337] [client 
178.59.182.161:13755] AH01215: TypeError: not all arguments converted during 
string formatting 
[/code]
-- 
https://mail.python.org/mailman/listinfo/python-list


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 right syntax 
>> to use near '(pagesID, host, ref, location, useros, browser, visits) VALUES 
>> (1, 'cyta.gr', '' at line 1")
>>
>> that is all i get form error. error_log doesnt produce errors when iam trying
>>
>> 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, domain, ref, location, 
>> useros, browser, lastvisit, domain) )
>>
>> WHY the valued aren't getting substituted wi the aeguments i give it in to 
>> work with?
>
> The % construct is Python 2 and no longer supported in Python 3. You should 
> read up on the "{}" and format method.
>
> https://docs.python.org/3/tutorial/inputoutput.html#fancier-output-formatting

Rubbish, it works just fine in Python 3:

Python 3.6.0 (default, Jan  1 2017, 22:51:19)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> '%s %s' % ('Hello', 'world')
'Hello world'

And contrary to popular belief, it's not even deprecated (although use
of the newer format method is encouraged). What's more, in this case
it's part of the PEP 249 DBAPI specification:
https://www.python.org/dev/peps/pep-0249/#paramstyle. As far as I know
pymysql and DBAPI libraries in general don't even accept "{}".
-- 
https://mail.python.org/mailman/listinfo/python-list


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 Update
>> statement syntax.
>
> 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) )
>
> output of error-log:

You need to change the placeholders back. The poster who told you to
replace them was misinformed.
-- 
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) VALUES (%s, %s, %s, %s, %s, %s, %s) WHERE host LIKE "%%s%" 
''', 



(pID, domain, ref, location, useros, 
browser, lastvisit, domain) )

but now the problem is how to exact;y type the Where HOST like "%%%"

I MEAN HOW TO DIFFERENTIATE '%S' FROM LITERAL '%' character.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Who are the "spacists"?

2017-03-26 Thread Wildman via Python-list
On Sun, 26 Mar 2017 15:18:06 +0200, Mikhail V wrote:

> On 26 March 2017 at 06:16, Wildman via Python-list
>  wrote:
>> On Tue, 21 Mar 2017 15:15:14 +0100, Mikhail V wrote:
>>
>>> And on linux console, by default one does not even have good
>>> possibilities for text-mode pseudographics, it was more relevant
>>> in DOS where one had rich possibilities and programmable
>>> binary fonts.
>>>
>>> Mikhail
>>
>> Nonsense.
> 
> Why? IIRC I can do good pseudographics on linux only with extended
> unicode character sets, so yes it is possible, is that what you mean?

No.  The same ASCII character set that was available in DOS is
available in Linux without unicode.

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


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 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 space as in "%%s%" ?
>
> Στις Κυρ, 26 Μαρ 2017 στις 5:32 μ.μ., ο/η INADA Naoki
>  έγραψε:
>>
>> > I MEAN HOW TO DIFFERENTIATE '%S' FROM LITERAL '%' character.
>> >
>>
>> >>> '%% %s %%s' % (42,)
>> '% 42 %s'
>>
>> Use %%
>
> --
> What is now proved was at first only imagined!
-- 
https://mail.python.org/mailman/listinfo/python-list


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 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) )
> 
> but now the problem is how to exact;y type the Where HOST like "%%%"
> 
> I MEAN HOW TO DIFFERENTIATE '%S' FROM LITERAL '%' character.


as a quick thought (untested) it is probably best to have %s as your 
parameter for the Like clause & ad the sql wild-cards (% symbols) to the 
data you pass in as I think the expansion of %s adds quote marks which 
will certainly cause the sql parser issues.
  


-- 
'Charity ain't giving people what you wants to give, it's giving people 
what they need to get.'
(Hogfather)
-- 
https://mail.python.org/mailman/listinfo/python-list


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
> >> replace them was misinformed.
> > 
> > okey altered them back to
> > 
> > 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, domain, ref, location, useros,
> > 
>   
>   
>   
> 
> browser, lastvisit, domain) )
> > 
> > but now the problem is how to exact;y type the Where HOST like "%%%"
> > 
> > I MEAN HOW TO DIFFERENTIATE '%S' FROM LITERAL '%' character.
> 
> 
> as a quick thought (untested) it is probably best to have %s as your 
> parameter for the Like clause & ad the sql wild-cards (% symbols) to the 
> data you pass in as I think the expansion of %s adds quote marks which 
> will certainly cause the sql parser issues.

How do you propose writing that cur.execute statement Alister?

-- 
https://mail.python.org/mailman/listinfo/python-list


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
enough, things got worse.

-- 
https://mail.python.org/mailman/listinfo/python-list


Installation issue with Python 3.6.1 for 64 bit Windows

2017-03-26 Thread arjun.janah

Sent from my T-Mobile 4G LTE Device
Hello,
I am using an HP PC, brought in 2009, which currently has on it Windows 7 
Ultimate, Service Pack 1. 

The processor is an AMD Turion 64 X2 Mobile Technology TL-62 2.10 GHz.

Installed memory is 4.00 GB (3.75 GB usable)

System type is 64-bit operating system.

I went to https://www.python.org/downloads/windows/ and chose the following: 
Download Windows x86-64 executable installerThe downloaded file appeared, in my 
Downloads folder, as:

python-3.6.1-amd64.exe, with a filesize of 30,657 KB.

I ran the file and it appeared to install properly. But when I tried to run 
Python from the Windows All Programs menu tab, I got the following message, in 
a small window by the window with a black screen:
--
python.exe - System Error
The program can't start because api-ms-win-crt-runtime-l1-1-0.dll is missing 
from your computer. Try reinstalling the program to fix this 
problem.--

I tried the following:

(a) restarting Windows and trying again: same result;

(a) running the installer file again and selecting repair:
this stalled for a long time so I had to abort it;

(b) restarting my computer, running the installer file again and selecting 
uninstall: this uninstalled Python, so it said;

(c) running the installer file again and choosing install: this installed 
Python afresh. But then I had the same problem as at the start when I tried to 
run Python.

Please advise.

Thanks

Arjun Janah < arjun.ja...@gmail.com >


-- 
https://mail.python.org/mailman/listinfo/python-list


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' FROM LITERAL '%' character.
> >
>
> >>> '%% %s %%s' % (42,)
> '% 42 %s'
>
> Use %%
>
-- 
What is now proved was at first only imagined!
-- 
https://mail.python.org/mailman/listinfo/python-list


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 '(pagesID, host, ref, location, useros, browser, visits) VALUES
(1, 'cyta.gr', '' at line 1")

How to test this further?

Στις Κυρ, 26 Μαρ 2017 στις 5:38 μ.μ., ο/η INADA Naoki <
songofaca...@gmail.com> έγραψε:

> 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 space as in "%%s%" ?
> >
> > Στις Κυρ, 26 Μαρ 2017 στις 5:32 μ.μ., ο/η INADA Naoki
> >  έγραψε:
> >>
> >> > I MEAN HOW TO DIFFERENTIATE '%S' FROM LITERAL '%' character.
> >> >
> >>
> >> >>> '%% %s %%s' % (42,)
> >> '% 42 %s'
> >>
> >> Use %%
> >
> > --
> > What is now proved was at first only imagined!
>
-- 
What is now proved was at first only imagined!
-- 
https://mail.python.org/mailman/listinfo/python-list


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 of output in the error-log even with this attempt.


Don't do that! Even if you fix the SQL errors, this is vulnerable to code
injection attacks. If the caller can fool you into using a specially-made
string for any of those parameters (pID, domain, ref, ...) they can execute
any SQL code they like, without your knowledge.

https://xkcd.com/327/

http://www.explainxkcd.com/wiki/index.php/Little_Bobby_Tables


See also:

http://bobby-tables.com/



-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.

-- 
https://mail.python.org/mailman/listinfo/python-list


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 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) )
>
> but now the problem is how to exact;y type the Where HOST like "%%%"
>
> I MEAN HOW TO DIFFERENTIATE '%S' FROM LITERAL '%' character.

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 '%%%s%%' % domain or '%{}%'.format(domain).
-- 
https://mail.python.org/mailman/listinfo/python-list


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 '%%%s%%' % domain or '%{}%'.format(domain).

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" ''', 



(pID, domain, ref, location, useros, 
browser, lastvisit, domain) )


and i received no error in the error_log but
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")

which you can see at http://superhost.gr

You said somethign about concatenating the literal % in the SQL to which i 
didnt actually i understand how to implement.
-- 
https://mail.python.org/mailman/listinfo/python-list


Text-mode apps (Was :Who are the "spacists"?)

2017-03-26 Thread Mikhail V
On 26 March 2017 at 16:28, Wildman via Python-list
 wrote:
> On Sun, 26 Mar 2017 15:18:06 +0200, Mikhail V wrote:
>
>> On 26 March 2017 at 06:16, Wildman via Python-list
>>  wrote:
>>> On Tue, 21 Mar 2017 15:15:14 +0100, Mikhail V wrote:
>>>
 And on linux console, by default one does not even have good
 possibilities for text-mode pseudographics, it was more relevant
 in DOS where one had rich possibilities and programmable
 binary fonts.

 Mikhail
>>>
>>> Nonsense.
>>
>> Why? IIRC I can do good pseudographics on linux only with extended
>> unicode character sets, so yes it is possible, is that what you mean?
>
> No.  The same ASCII character set that was available in DOS is
> available in Linux without unicode.

Ok, now I have read that one can change the encoding in the terminal
to get same table drawing characters (if one does not want to use
unicode).
But such a question: can one do it programmaticaly?
And more important: can one use binary (bitmap) fonts in default modern
linux console? If yes, can one patch them with custom tiles at
the application start?
In DOS, (I don't remember if in all versions or only some)
one could do all this and this opens very rich possibilities for
approximating of objects with tiles. The only limitations
that one uses 255 tiles, but even this enables to build
whole 'worlds' and state of the art apps. So I would call this
pseudographics and not few sticks and corner tiles
(which I cannot even define and upload easily).
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python question

2017-03-26 Thread Steve D'Aprano
On Sun, 26 Mar 2017 10:35 pm, Cameron Simpson wrote:

> On 26Mar2017 20:55, Steve D'Aprano  wrote:
>>On Sun, 26 Mar 2017 01:55 pm, c...@zip.com.au wrote:
>>> 1: He BCCed the list, not us individually. Look at the headers.
>>
>>BCCed addresses aren't visible in the headers. That's why they're BLIND
>>CC.
> 
> Of course, but the received headers etc show it passed though the list.

Sending to the list is not a bad thing. We know the OP sent to the list,
because his post appeared on the list :-)

The question is whether he BCCed a bunch of regulars or not.

[...]
> If the headers say it went though the list, _that_ copy went through the
> list, _not_ to your personal address (well, not from him; of course the
> list delivered it to you).

Unfortunately I deleted the email so I can't look at the headers, but
nevertheless I can categorically say that it didn't come from the mailing
list, because the python-list@python.org mailing list doesn't have my
address. I've always read this though the newsgroup.

I do still have the relevant mail logs:

Mar 25 03:08:36 ando postfix/smtpd[24188]: connect from
  mail-wr0-f194.google.com[209.85.128.194]
Mar 25 03:08:37 ando postfix/smtpd[24188]: 2093D1204E2:
  client=mail-wr0-f194.google.com[209.85.128.194]
Mar 25 03:08:37 ando postfix/cleanup[24192]: 2093D1204E2:
  message-id=
Mar 25 03:08:37 ando postfix/qmgr[3004]: 2093D1204E2:
  from=, size=3258, nrcpt=1 (queue active)
Mar 25 03:08:38 ando postfix/smtpd[24188]: disconnect from
  mail-wr0-f194.google.com[209.85.128.194]

I'm not an expert, but to me that looks pretty convincing that the email
came directly from Google, not from the mailing list. Am I wrong?


>>Your interpretation doesn't explain why I received a copy sent to my
>>personal email address. I read this via the newsgroup comp.lang.python,
>>not the mailing list, and I'm not subscribed to the email mailing list. If
>>the OP had merely BCCed the mailing list, I wouldn't have received a copy
>>in my personal inbox.
> 
> Fair point. Though I thought I only got one copy, might be wrong.

Maybe you weren't one of the people he BCCed :-)





-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.

-- 
https://mail.python.org/mailman/listinfo/python-list


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" ''', 



(pID, domain, ref, location, useros, 
browser, lastvisit, domain) )

i just tried both of these 3 ways and the database wrapper failed on all of 
them respectively.

they gave no error_log output though just the usual
ProgrammingError(1064, .)
-- 
https://mail.python.org/mailman/listinfo/python-list


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 string before you pass it in, i.e. '%' + domain +
>> '%' or '%%%s%%' % domain or '%{}%'.format(domain).
>
> 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" ''',
>   
>   
>   
>   (pID, domain, ref, location, 
> useros, browser, lastvisit, domain) )
>
>
> and i received no error in the error_log but
> 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")
>
> which you can see at http://superhost.gr
>
> You said somethign about concatenating the literal % in the SQL to which i 
> didnt actually i understand how to implement.

Stop panicking.

Stop just trying one thing very quickly, getting an error message, and
firing a post back to this list.

Slow down and read the messages you are getting.

You have already been told about UPDATE queries not using this syntax,
and the error message is referring to that. You have an error in your
SQL syntax; **check the manual**.

This is the same problem that you had the last time you were here on
this list - you had a different email address then, and I can't
remember what name you were going by, but I won't quickly forget
superhost.gr, which at the moment looks like Geocities found a new
domain name.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Text-mode apps (Was :Who are the "spacists"?)

2017-03-26 Thread Chris Angelico
On Mon, Mar 27, 2017 at 2:17 AM, Mikhail V  wrote:
>>> Why? IIRC I can do good pseudographics on linux only with extended
>>> unicode character sets, so yes it is possible, is that what you mean?
>>
>> No.  The same ASCII character set that was available in DOS is
>> available in Linux without unicode.
>
> Ok, now I have read that one can change the encoding in the terminal
> to get same table drawing characters (if one does not want to use
> unicode).

Just use Unicode. Everything else, these days, is a subset of Unicode
anyway. Unless you're stuck on the default Windows shell/terminal, you
should be able to use UTF-8 everywhere and have the entire Unicode
range available. For example, the IBM OEM box-drawing characters are
available in Code Page 437... or as Unicode code points in the U+25xx
range.

> But such a question: can one do it programmaticaly?

Set everything to UTF-8 and you don't have to.

> And more important: can one use binary (bitmap) fonts in default modern
> linux console? If yes, can one patch them with custom tiles at
> the application start?

If you really need something completely custom, it's not text any
more. For example, suppose you redefine all the character images, and
then someone copies and pastes into a web browser - can they search
the web for the characters you're displaying, and will they mean the
same things? If you've redefined images arbitrarily, they won't.

More likely, you don't truly need something custom - what you need is
a different subset of characters (maybe you need to mix Latin, Greek,
and Hebrew letters, in order to show interlinear translation of the
Bible). Instead of messing around with character sets, you can just
use Unicode and have all of them available.

> In DOS, (I don't remember if in all versions or only some)
> one could do all this and this opens very rich possibilities for
> approximating of objects with tiles. The only limitations
> that one uses 255 tiles, but even this enables to build
> whole 'worlds' and state of the art apps. So I would call this
> pseudographics and not few sticks and corner tiles
> (which I cannot even define and upload easily).

Yeah; if my memory serves me, this was an IBM BIOS feature, so all
versions of DOS would be equally able to do it. But it's basically a
form of tile graphics, not text. Given how easily graphical programs
can be built these days, I would strongly recommend that, rather than
abusing pseudo-text as pseudo-graphics. Pick up Tk or GTK or wxWindows
or something, or build your app to run in a web browser, or something
like that.

If what you're doing really is text, just with custom images, you MAY
be able to ask your users to install a TTF or something. But I
wouldn't use a program that demands that I reconfigure my terminal.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Text-mode apps (Was :Who are the "spacists"?)

2017-03-26 Thread Chris Angelico
On Mon, Mar 27, 2017 at 2:37 AM, Chris Angelico  wrote:
> Just use Unicode. Everything else, these days, is a subset of Unicode
> anyway.

(Caveat: There are a few counter-examples to my statement, but I very
much doubt that someone who's talking about PC OEM graphics is going
to be running into them.)

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


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"
> ''', (pID, domain, ref, location, useros, browser, lastvisit, domain) )
> 
> and i received no error in the error_log but
> 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")

Start by following the instructions given:

check the manual that corresponds to your MariaDB server version 
for the right syntax to use

just like the error message tells you to do.

Are you sure that the domain needs to have leading and trailing percentage
signs? "%cyta.gr%" instead of "cyta.gr"?

Are you sure that the LIKE clause needs double quotes?

LIKE "%s"

Perhaps MariaDB requires single quotes:

LIKE '%s'

or perhaps no quotes at all:

LIKE %s


But I'm just guessing, because I haven't read the MariaDB manual. You should
do so.


> which you can see at http://superhost.gr

Ah, Nikos, its been a long time! I thought I recognised your style of
posting.




-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.

-- 
https://mail.python.org/mailman/listinfo/python-list


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
> >> 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 '%%%s%%' % domain or '%{}%'.format(domain).
> >
> > 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" 
> > ''',
> > 
> > 
> > 
> > (pID, domain, ref, 
> > location, useros, browser, lastvisit, domain) )
> >
> >
> > and i received no error in the error_log but
> > 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")
> >
> > which you can see at http://superhost.gr
> >
> > You said somethign about concatenating the literal % in the SQL to which i 
> > didnt actually i understand how to implement.
> 
> Stop panicking.
> 
> Stop just trying one thing very quickly, getting an error message, and
> firing a post back to this list.
> 
> Slow down and read the messages you are getting.
> 
> You have already been told about UPDATE queries not using this syntax,
> and the error message is referring to that. You have an error in your
> SQL syntax; **check the manual**.

> This is the same problem that you had the last time you were here on
> this list - you had a different email address then, and I can't
> remember what name you were going by, but I won't quickly forget
> superhost.gr, which at the moment looks like Geocities found a new
> domain name.
> 
> ChrisA

I'am reading all the answers and trying everything mentioned.

As for the SQL syntax i dont see where the error is.
I use many UPDATE statements within my scripts in exactyly the same why i have 
been showing them to you.
The only UPDATE is failing is this one with the LIKE clause.

I think that Ian's is correct saying that the substitution is ain't done as we 
intend form the database wrapper which is PyMYSQL.

And last but not least it would be nice if you actually made a contributing 
comment regarding to my questions(which bothers me 3 days in a row by now) 
instead of making ironic remarks related to how my website looks like 
aesthitically to you.
-- 
https://mail.python.org/mailman/listinfo/python-list


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, 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) )
> > 
> > and i received no error in the error_log but
> > 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")
> 
> Start by following the instructions given:
> 
> check the manual that corresponds to your MariaDB server version 
> for the right syntax to use
> 
> just like the error message tells you to do.
> 
> Are you sure that the domain needs to have leading and trailing percentage
> signs? "%cyta.gr%" instead of "cyta.gr"?
> 
> Are you sure that the LIKE clause needs double quotes?
> 
> LIKE "%s"
> 
> Perhaps MariaDB requires single quotes:
> 
> LIKE '%s'
> 
> or perhaps no quotes at all:
> 
> LIKE %s
> 
> 
> But I'm just guessing, because I haven't read the MariaDB manual. You should
> do so.
> 
> 
> > 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?!

Yeap still trying to make my webiste better and better every day.

As for MariaDB i tried with single/double/no_quoting at all and it still 
produces 
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")

I think that Ian Kelly is right and it has soemthign to do with the databse 
wrapper not substituting properly the actual string contain in the LIKE clause 
between the double quotes.

Perhaps i need to change pymysql with some other database interface or there is 
something other than that?
-- 
https://mail.python.org/mailman/listinfo/python-list


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
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Installation issue with Python 3.6.1 for 64 bit Windows

2017-03-26 Thread Sibylle Koczian

Am 26.03.2017 um 06:01 schrieb arjun.janah:


Hello,
I am using an HP PC, brought in 2009, which currently has on it Windows 7 
Ultimate, Service Pack 1.


Did you do all Windows updates?


System type is 64-bit operating system.

I went to https://www.python.org/downloads/windows/ and chose the following: 
Download Windows x86-64 executable installerThe downloaded file appeared, in my 
Downloads folder, as:

python-3.6.1-amd64.exe, with a filesize of 30,657 KB.

I ran the file and it appeared to install properly. But when I tried to run 
Python from the Windows All Programs menu tab, I got the following message, in 
a small window by the window with a black screen:
--
python.exe - System Error
The program can't start because api-ms-win-crt-runtime-l1-1-0.dll is missing 
from your computer. Try reinstalling the program to fix this 
problem.--

I tried the following:

(a) restarting Windows and trying again: same result;

(a) running the installer file again and selecting repair:
this stalled for a long time so I had to abort it;

(b) restarting my computer, running the installer file again and selecting 
uninstall: this uninstalled Python, so it said;

(c) running the installer file again and choosing install: this installed 
Python afresh. But then I had the same problem as at the start when I tried to 
run Python.



You need the dll mentioned in the error message, and you won't get it by 
repeatedly installing Python (I don't know why the message tells you to 
do that ...). You will have to get it from Microsoft instead. Googling 
the name of the dll will probably lead you to it quickly, the problem 
seems to be quite common.



--
https://mail.python.org/mailman/listinfo/python-list


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, domain, ref, location, useros, browser, lastvisit, domain_query) )

which as i saiddisplays no error in the error_log output just the 

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")

and i'am totally stuck.
-- 
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 + '%'
>> >
>> > 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, domain, ref, location, useros, browser, lastvisit, domain) )
>> >
>> > and i received no error in the error_log but
>> > 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")
>>
>> Start by following the instructions given:
>>
>> check the manual that corresponds to your MariaDB server version
>> for the right syntax to use
>>
>> just like the error message tells you to do.
>>
>> Are you sure that the domain needs to have leading and trailing percentage
>> signs? "%cyta.gr%" instead of "cyta.gr"?
>>
>> Are you sure that the LIKE clause needs double quotes?
>>
>> LIKE "%s"
>>
>> Perhaps MariaDB requires single quotes:
>>
>> LIKE '%s'
>>
>> or perhaps no quotes at all:
>>
>> LIKE %s
>>
>>
>> But I'm just guessing, because I haven't read the MariaDB manual. You should
>> do so.
>>
>>
>> > which you can see at http://superhost.gr
>>
>> Ah, Nikos, its been a long time! I thought I recognised your style of
>> posting.

Not long enough!
>
>
> Howdy Steve!
> Yes its me and yes its have been a long time! How are you?!
>
> Yeap still trying to make my webiste better and better every day.
>
> As for MariaDB i tried with single/double/no_quoting at all and it still 
> produces
> 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")
>
> I think that Ian Kelly is right and it has soemthign to do with the databse 
> wrapper not substituting properly the actual string contain in the LIKE 
> clause between the double quotes.
>
> Perhaps i need to change pymysql with some other database interface or there 
> is something other than that?
> --
> https://mail.python.org/mailman/listinfo/python-list



-- 
Joel Goldstick
http://joelgoldstick.com/blog
http://cc-baseballstats.info/stats/birthdays
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Installation issue with Python 3.6.1 for 64 bit Windows

2017-03-26 Thread eryk sun
On Sun, Mar 26, 2017 at 4:01 AM, arjun.janah  wrote:
>
> I ran the file and it appeared to install properly. But when I tried to run 
> Python from
> the Windows All Programs menu tab, I got the following message, in a small
> window by the window with a black screen:
> --
> python.exe - System Error
> The program can't start because api-ms-win-crt-runtime-l1-1-0.dll is missing 
> from
> your computer. Try reinstalling the program to fix this problem.
>
> I tried the following:
>
> (a) restarting Windows and trying again: same result;
>
> (a) running the installer file again and selecting repair:
> this stalled for a long time so I had to abort it;
>
> (b) restarting my computer, running the installer file again and selecting 
> uninstall:
> this uninstalled Python, so it said;
>
> (c) running the installer file again and choosing install: this installed 
> Python afresh.
> But then I had the same problem as at the start when I tried to run Python.

Python's installer should try to install the Universal C runtime
update, but this seems to fail frequently. If you want to help improve
the installer, zip up Python's installation logs that are in your
%Temp% directory to a single zip file; open an issue on
bugs.python.org; and attach the zip file to the issue.

You probably didn't get the CRT update from Windows Update because you
don't have the option enabled to install recommended updates. Anyway,
you can manually download and install Windows6.1-KB3118401-x64.msu
(the 64-bit version for NT 6.1, i.e. Windows 7) from the following
site:

https://www.microsoft.com/en-us/download/details.aspx?id=50410
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Text-mode apps (Was :Who are the "spacists"?)

2017-03-26 Thread Mikhail V
On 26 March 2017 at 17:37, Chris Angelico  wrote:
> On Mon, Mar 27, 2017 at 2:17 AM, Mikhail V  wrote:
 Why? IIRC I can do good pseudographics on linux only with extended
 unicode character sets, so yes it is possible, is that what you mean?
>>>
>>> No.  The same ASCII character set that was available in DOS is
>>> available in Linux without unicode.
>>
>> Ok, now I have read that one can change the encoding in the terminal
>> to get same table drawing characters (if one does not want to use
>> unicode).
>
> Just use Unicode. Everything else, these days, is a subset of Unicode
> anyway. Unless you're stuck on the default Windows shell/terminal, you
> should be able to use UTF-8 everywhere and have the entire Unicode
> range available.

Yes I am 'stuck' on Windows console, and I use it for what it is
made for - running command line tools.
On Win 7 and 10, I can see UTF-8 chars everywhere.
To be precise, to see entire range of chars, you need a _font_
in which someone have drawn those chars according to their
understanding how those glyphs must look, nothing more.

No need to say, that even for text only, monospaced cannot
represent them even close to satisfying, and for Arabic for example they
look ass ugly in monospaced.
IOW, even a console-like apps would use proportional fonts in the future.


>
>> But such a question: can one do it programmaticaly?
>
> Set everything to UTF-8 and you don't have to.
>
>> And more important: can one use binary (bitmap) fonts in default modern
>> linux console? If yes, can one patch them with custom tiles at
>> the application start?
>
> If you really need something completely custom, it's not text any
> more.

Obvious fact, but if I need e.g. rounded corners in table drawing
characters? Or I just want to fix some characters which look especially ugly?
Create a new TTF? No, thanks, this would be worst nightmare to
do without a special tool (which have prices with several zeros, otherwise
just don't work and can even break things system-wide)

>
> More likely, you don't truly need something custom - what you need is
> a different subset of characters (maybe you need to mix Latin, Greek,
> and Hebrew letters, in order to show interlinear translation of the
> Bible). Instead of messing around with character sets, you can just
> use Unicode and have all of them available.

If I was to deal with multiple language charsets in _my own_ rendering
app, I would still use discrete encoding for inner algorithms.
i.e. I would place separate charsets on separate code ranges.
And for own standalone app, I would not use any TTF or
anything vector-based font, since why?

>
>> In DOS, (I don't remember if in all versions or only some)
>> one could do all this and this opens very rich possibilities for
>> approximating of objects with tiles. The only limitations
>> that one uses 255 tiles, but even this enables to build
>> whole 'worlds' and state of the art apps. So I would call this
>> pseudographics and not few sticks and corner tiles
>> (which I cannot even define and upload easily).
>
> Yeah; if my memory serves me, this was an IBM BIOS feature, so all
> versions of DOS would be equally able to do it. But it's basically a
> form of tile graphics, not text. Given how easily graphical programs
> can be built these days, I would strongly recommend that, rather than
> abusing pseudo-text as pseudo-graphics. Pick up Tk or GTK or wxWindows
> or something, or build your app to run in a web browser, or something
> like that.

Exactly, that is why I do so, and even if one wants to play around
with console hacking, there is not so many documented
ways to do it. In Windows, I can manually select raster fonts,
so in pure theory, one could hack it with custom tiles, but
since it is much easier to use a graphical library today,
too few people are interested in it.

Mikhail
-- 
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 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 Νίκος Βέργος
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 that is causing all this trouble

How would you write it?!

Στις Κυρ, 26 Μαρ 2017 στις 8:05 μ.μ., ο/η INADA Naoki <
songofaca...@gmail.com> έγραψε:

> 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.
>
-- 
What is now proved was at first only imagined!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Text-mode apps (Was :Who are the "spacists"?)

2017-03-26 Thread Chris Angelico
On Mon, Mar 27, 2017 at 3:57 AM, Mikhail V  wrote:
> On 26 March 2017 at 17:37, Chris Angelico  wrote:
>> On Mon, Mar 27, 2017 at 2:17 AM, Mikhail V  wrote:
> Why? IIRC I can do good pseudographics on linux only with extended
> unicode character sets, so yes it is possible, is that what you mean?

 No.  The same ASCII character set that was available in DOS is
 available in Linux without unicode.
>>>
>>> Ok, now I have read that one can change the encoding in the terminal
>>> to get same table drawing characters (if one does not want to use
>>> unicode).
>>
>> Just use Unicode. Everything else, these days, is a subset of Unicode
>> anyway. Unless you're stuck on the default Windows shell/terminal, you
>> should be able to use UTF-8 everywhere and have the entire Unicode
>> range available.
>
> Yes I am 'stuck' on Windows console, and I use it for what it is
> made for - running command line tools.

Not really stuck; even if you can't get off Windows, you should be
able to move off the ancient terminal that you get by default.

> On Win 7 and 10, I can see UTF-8 chars everywhere.
> To be precise, to see entire range of chars, you need a _font_
> in which someone have drawn those chars according to their
> understanding how those glyphs must look, nothing more.

Duh? If you want characters to display, you need a font yes...?

> No need to say, that even for text only, monospaced cannot
> represent them even close to satisfying, and for Arabic for example they
> look ass ugly in monospaced.
> IOW, even a console-like apps would use proportional fonts in the future.

Arabic text is written right-to-left. It's a lot more complicated than
just whether your font is monospaced or not, particularly when you mix
strongly-directional characters, weakly-directional characters,
non-directional characters, and explicit directionality markers. If
you mix RTL and LTR text, is the RTL text aligned to the right of the
page, or the left? There is a LOT more than just your font to take
care of here. If you want perfect handling of international text, you
basically need to use a Unicode-compliant text renderer - and
fortunately, most graphical engines these days come with exactly that.

>>> And more important: can one use binary (bitmap) fonts in default modern
>>> linux console? If yes, can one patch them with custom tiles at
>>> the application start?
>>
>> If you really need something completely custom, it's not text any
>> more.
>
> Obvious fact, but if I need e.g. rounded corners in table drawing
> characters? Or I just want to fix some characters which look especially ugly?
> Create a new TTF? No, thanks, this would be worst nightmare to
> do without a special tool (which have prices with several zeros, otherwise
> just don't work and can even break things system-wide)

Rounded corners?

╭─┬─╮
├─┼─┤
╰─┴─╯

A good font should show this as a rounded box with cross-lines through
it. The characters here are:

U+256D BOX DRAWINGS LIGHT ARC DOWN AND RIGHT
U+2500 BOX DRAWINGS LIGHT HORIZONTAL
U+252C BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
U+2500 BOX DRAWINGS LIGHT HORIZONTAL
U+256E BOX DRAWINGS LIGHT ARC DOWN AND LEFT
U+000A LINE FEED
U+251C BOX DRAWINGS LIGHT VERTICAL AND RIGHT
U+2500 BOX DRAWINGS LIGHT HORIZONTAL
U+253C BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
U+2500 BOX DRAWINGS LIGHT HORIZONTAL
U+2524 BOX DRAWINGS LIGHT VERTICAL AND LEFT
U+000A LINE FEED
U+2570 BOX DRAWINGS LIGHT ARC UP AND RIGHT
U+2500 BOX DRAWINGS LIGHT HORIZONTAL
U+2534 BOX DRAWINGS LIGHT UP AND HORIZONTAL
U+2500 BOX DRAWINGS LIGHT HORIZONTAL
U+256F BOX DRAWINGS LIGHT ARC UP AND LEFT
U+000A LINE FEED

And if you think that some characters look ugly, you can create a font
with just those characters in it. Thanks to font substitution, your
font should be used for the characters it defines, but anything it
doesn't will fall back on some other font, so you don't have to create
representations for hundreds of thousands of Unicode characters.

>> More likely, you don't truly need something custom - what you need is
>> a different subset of characters (maybe you need to mix Latin, Greek,
>> and Hebrew letters, in order to show interlinear translation of the
>> Bible). Instead of messing around with character sets, you can just
>> use Unicode and have all of them available.
>
> If I was to deal with multiple language charsets in _my own_ rendering
> app, I would still use discrete encoding for inner algorithms.
> i.e. I would place separate charsets on separate code ranges.
> And for own standalone app, I would not use any TTF or
> anything vector-based font, since why?

Separate code ranges? You mean like allocating U+03xx to Greek, U+04xx
to Cyrillic (Russian and friends), U+06xx to Arabic, etc? Sounds like
a good plan

>> Yeah; if my memory serves me, this was an IBM BIOS feature, so all
>> versions of DOS would be equally able to do it. But it's basically a
>> form of tile graphics, not text. Given how easily graphical programs
>

Re: Text-mode apps (Was :Who are the "spacists"?)

2017-03-26 Thread eryk sun
On Sun, Mar 26, 2017 at 3:37 PM, Chris Angelico  wrote:
>
> Just use Unicode. Everything else, these days, is a subset of Unicode
> anyway. Unless you're stuck on the default Windows shell/terminal, you
> should be able to use UTF-8 everywhere and have the entire Unicode
> range available.

The Windows console can render any character in the BMP, but it
requires configuring font linking for fallback fonts. It's Windows, so
of course the supported UTF format is UTF-16. The console's UTF-8
support (codepage 65001) is too buggy to even consider using it.

I don't know why you mention the shell. It has nothing to do with
this. But, for what it's worth, the cmd shell is a Unicode application
and always has been. It use the console's wide-character API.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Text-mode apps (Was :Who are the "spacists"?)

2017-03-26 Thread Steve D'Aprano
On Mon, 27 Mar 2017 02:37 am, Chris Angelico wrote:

> On Mon, Mar 27, 2017 at 2:17 AM, Mikhail V  wrote:
 Why? IIRC I can do good pseudographics on linux only with extended
 unicode character sets, so yes it is possible, is that what you mean?
>>>
>>> No.  The same ASCII character set that was available in DOS is
>>> available in Linux without unicode.
>>
>> Ok, now I have read that one can change the encoding in the terminal
>> to get same table drawing characters (if one does not want to use
>> unicode).
> 
> Just use Unicode. Everything else, these days, is a subset of Unicode
> anyway. Unless you're stuck on the default Windows shell/terminal, you
> should be able to use UTF-8 everywhere and have the entire Unicode
> range available. For example, the IBM OEM box-drawing characters are
> available in Code Page 437... or as Unicode code points in the U+25xx
> range.

You are absolutely correct in theory, but in practice the availability of
glyphs in most fonts is only a tiny proportion of the Unicode range. And
even when the glyphs are available, the quality often varies: for example,
in all of the monospaced fonts I've looked at, the superscripts ¹²³ are a
different size to ⁴⁵⁶⁷⁸⁹⁰, both vertically and horizontally. And I've come
across a few fonts where the box drawing characters don't all line up.

Don't misunderstand me: Unicode is a HUGE improvement over the Bad Old Days
of dozens of incompatible character sets. But let's not pretend that it
makes it *easy*.



[...]
>> And more important: can one use binary (bitmap) fonts in default modern
>> linux console? If yes, can one patch them with custom tiles at
>> the application start?
> 
> If you really need something completely custom, it's not text any
> more. 

That's not quite right. Unicode includes 137000 or so Private Use
Characters, which anyone can define for their own purposes, "by private
agreement". There's an unofficial registry of such private use characters
here:

http://www.evertype.com/standards/csur/

More info here:

https://en.wikipedia.org/wiki/Private_Use_Areas



> For example, suppose you redefine all the character images, and 
> then someone copies and pastes into a web browser - can they search
> the web for the characters you're displaying, and will they mean the
> same things? If you've redefined images arbitrarily, they won't.
> 
> More likely, you don't truly need something custom - what you need is
> a different subset of characters (maybe you need to mix Latin, Greek,
> and Hebrew letters, in order to show interlinear translation of the
> Bible). Instead of messing around with character sets, you can just
> use Unicode and have all of them available.

Assuming you have a text widget which is capable of displaying LTR and RTL
text, and support for all the glyphs you need.




-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Text-mode apps (Was :Who are the "spacists"?)

2017-03-26 Thread eryk sun
On Sun, Mar 26, 2017 at 5:29 PM, Chris Angelico  wrote:
> Rounded corners?
>
> ╭─┬─╮
> ├─┼─┤
> ╰─┴─╯

This prints fine in the Windows console with Consolas as the font, but
the older Courier New and Lucida Console fonts lack glyphs for the
rounded corners.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Installation issue with Python 3.6.1 for 64 bit Windows

2017-03-26 Thread Arjun Janah
Thank you, Eryk Sun.

On Mar 26, 2017 12:40 PM, "eryk sun"  wrote:

> On Sun, Mar 26, 2017 at 4:01 AM, arjun.janah 
> wrote:
> >
> > I ran the file and it appeared to install properly. But when I tried to
> run Python from
> > the Windows All Programs menu tab, I got the following message, in a
> small
> > window by the window with a black screen:
> > --
> > python.exe - System Error
> > The program can't start because api-ms-win-crt-runtime-l1-1-0.dll is
> missing from
> > your computer. Try reinstalling the program to fix this problem.
> >
> > I tried the following:
> >
> > (a) restarting Windows and trying again: same result;
> >
> > (a) running the installer file again and selecting repair:
> > this stalled for a long time so I had to abort it;
> >
> > (b) restarting my computer, running the installer file again and
> selecting uninstall:
> > this uninstalled Python, so it said;
> >
> > (c) running the installer file again and choosing install: this
> installed Python afresh.
> > But then I had the same problem as at the start when I tried to run
> Python.
>
> Python's installer should try to install the Universal C runtime
> update, but this seems to fail frequently. If you want to help improve
> the installer, zip up Python's installation logs that are in your
> %Temp% directory to a single zip file; open an issue on
> bugs.python.org; and attach the zip file to the issue.
>
> You probably didn't get the CRT update from Windows Update because you
> don't have the option enabled to install recommended updates. Anyway,
> you can manually download and install Windows6.1-KB3118401-x64.msu
> (the 64-bit version for NT 6.1, i.e. Windows 7) from the following
> site:
>
> https://www.microsoft.com/en-us/download/details.aspx?id=50410
>
-- 
https://mail.python.org/mailman/listinfo/python-list


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 syntax.

I cannot understand where the error is.
Could you how it to me please?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Text-mode apps (Was :Who are the "spacists"?)

2017-03-26 Thread Chris Angelico
On Mon, Mar 27, 2017 at 4:38 AM, eryk sun  wrote:
> On Sun, Mar 26, 2017 at 3:37 PM, Chris Angelico  wrote:
>>
>> Just use Unicode. Everything else, these days, is a subset of Unicode
>> anyway. Unless you're stuck on the default Windows shell/terminal, you
>> should be able to use UTF-8 everywhere and have the entire Unicode
>> range available.
>
> The Windows console can render any character in the BMP, but it
> requires configuring font linking for fallback fonts. It's Windows, so
> of course the supported UTF format is UTF-16. The console's UTF-8
> support (codepage 65001) is too buggy to even consider using it.

Is it actually UTF-16, or is it UCS-2?

> I don't know why you mention the shell. It has nothing to do with
> this. But, for what it's worth, the cmd shell is a Unicode application
> and always has been. It use the console's wide-character API.

Because a lot of people on Windows don't understand the distinction,
and it's common to hear people talk about "cmd.exe" when they really
mean the graphical display. But I'm aware that pedantic correctness
separates them completely.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


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 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) VALUES (%s, %s, %s, %s, %s, %s, %s) WHERE
>> > host LIKE "%%s%" ''',
>> > 
>> > 
>> (pID, domain, ref, location, useros,
>> > 
>> > 
>> browser, lastvisit, domain) )
>> > 
>> > but now the problem is how to exact;y type the Where HOST like "%%%"
>> > 
>> > I MEAN HOW TO DIFFERENTIATE '%S' FROM LITERAL '%' character.
>> 
>> 
>> as a quick thought (untested) it is probably best to have %s as your
>> parameter for the Like clause & ad the sql wild-cards (% symbols) to
>> the data you pass in as I think the expansion of %s adds quote marks
>> which will certainly cause the sql parser issues.
> 
> How do you propose writing that cur.execute statement Alister?


cur.execute('''UPDATE visitors SET (pagesID, host, ref, location,
>> > useros, browser, visits) VALUES (%s, %s, %s, %s, %s, %s, %s) WHERE
>> > host LIKE %s '''

but you will need to amend the data  you pass so that the last element 
has the surrounding % characters .


-- 
T-1's congested due to porn traffic to the news server.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Text-mode apps (Was :Who are the "spacists"?)

2017-03-26 Thread Steve D'Aprano
On Mon, 27 Mar 2017 03:57 am, Mikhail V wrote:

[...]
>>> And more important: can one use binary (bitmap) fonts in default modern
>>> linux console? If yes, can one patch them with custom tiles at
>>> the application start?
>>
>> If you really need something completely custom, it's not text any
>> more.
> 
> Obvious fact, but if I need e.g. rounded corners in table drawing
> characters? Or I just want to fix some characters which look especially
> ugly? Create a new TTF? No, thanks, this would be worst nightmare to
> do without a special tool (which have prices with several zeros, otherwise
> just don't work and can even break things system-wide)

Don't be silly. It took me ten seconds on Google to find this:

https://birdfont.org/

It is no charge for an open source licence, or $5 USD for a commercial
licence. If that's too cheap, you can use FontCreator at just $79:

http://www.high-logic.com/font-editor/fontcreator.html



>> More likely, you don't truly need something custom - what you need is
>> a different subset of characters (maybe you need to mix Latin, Greek,
>> and Hebrew letters, in order to show interlinear translation of the
>> Bible). Instead of messing around with character sets, you can just
>> use Unicode and have all of them available.
> 
> If I was to deal with multiple language charsets in _my own_ rendering
> app, I would still use discrete encoding for inner algorithms.
> i.e. I would place separate charsets on separate code ranges.

Why? Because you think you know better than the thousands of professionals
who have worked with text formats for decades?


> And for own standalone app, I would not use any TTF or
> anything vector-based font, since why?

Right, because your users will *love* to see their native language displayed
in a crappy bitmapped font with jagged or blurry edges.



-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Text-mode apps (Was :Who are the "spacists"?)

2017-03-26 Thread Chris Angelico
On Mon, Mar 27, 2017 at 4:43 AM, Steve D'Aprano
 wrote:
> On Mon, 27 Mar 2017 02:37 am, Chris Angelico wrote:
>
>> Just use Unicode. Everything else, these days, is a subset of Unicode
>> anyway. Unless you're stuck on the default Windows shell/terminal, you
>> should be able to use UTF-8 everywhere and have the entire Unicode
>> range available. For example, the IBM OEM box-drawing characters are
>> available in Code Page 437... or as Unicode code points in the U+25xx
>> range.
>
> You are absolutely correct in theory, but in practice the availability of
> glyphs in most fonts is only a tiny proportion of the Unicode range. And
> even when the glyphs are available, the quality often varies: for example,
> in all of the monospaced fonts I've looked at, the superscripts ¹²³ are a
> different size to ⁴⁵⁶⁷⁸⁹⁰, both vertically and horizontally. And I've come
> across a few fonts where the box drawing characters don't all line up.
>
> Don't misunderstand me: Unicode is a HUGE improvement over the Bad Old Days
> of dozens of incompatible character sets. But let's not pretend that it
> makes it *easy*.

Unicode makes it about as easy as it can possibly be, given the
diversity of human languages and their various needs, plus the reality
that nobody has infinite resources for creating fonts. The most
important thing is that you have a single universal specification that
governs the interpretation of text, which means you can aim for that
standard, and if a renderer doesn't match up to it, that's a bug that
can be fixed, not behaviour that has to be maintained for backward
compatibility. So, for instance, Eryk Sun commented that my rounded
box example didn't render correctly in all fonts - but in the future,
a new version of those fonts could be released, adding support for
those characters. We *know* that the code points I used are
permanently and irrevocably allocated to the purposes I used them for,
so we can all be confident that they'll be used correctly if at all.

>>> And more important: can one use binary (bitmap) fonts in default modern
>>> linux console? If yes, can one patch them with custom tiles at
>>> the application start?
>>
>> If you really need something completely custom, it's not text any
>> more.
>
> That's not quite right. Unicode includes 137000 or so Private Use
> Characters, which anyone can define for their own purposes, "by private
> agreement". There's an unofficial registry of such private use characters
> here:
>
> http://www.evertype.com/standards/csur/
>
> More info here:
>
> https://en.wikipedia.org/wiki/Private_Use_Areas

This is true, but at some point, it's not text any more. The PUAs are
great if you're working with non-standard forms of text (eg Klingon,
or Elvish), but aren't well suited to arbitrary graphics. You should
be able to copy and paste text from one application into another and
have it retain its meaning; the PUAs weaken this guarantee in that the
applications have to agree to coexist, but within that, the same
ability to copy and paste should hold. It sounds like Mikhail is
trying to warp the console into something pseudo-graphical like a
Roguelike game, but instead of designing the game around available
glyphs, wants to design the glyphs to suit the game - and at that
point, it's time to just go graphical, IMO.

>> More likely, you don't truly need something custom - what you need is
>> a different subset of characters (maybe you need to mix Latin, Greek,
>> and Hebrew letters, in order to show interlinear translation of the
>> Bible). Instead of messing around with character sets, you can just
>> use Unicode and have all of them available.
>
> Assuming you have a text widget which is capable of displaying LTR and RTL
> text, and support for all the glyphs you need.

This is true. Fortunately, some measure of this is available in all
the major GUI toolkits, although some applications need to have their
own handling too. But here's what it takes to have full Unicode
support in my MUD client:

1) Use GTK and Pango. That's the biggest part.
2) Due to the nature of MUDs, RTL text is still left-justified.
3) Due to the interaction of left-justified RTL text and indentation,
special handling is needed for lines that begin with spaces and/or
tabs and then an RTL character. (Solution: Prepend U+200E
LEFT-TO-RIGHT MARK.)
4) Individual lines may be painted in multiple colours, so the text
gets divided up and measured in pieces. I let Pango do the actual
measurements.

That's about it. Basically I just let Pango do all the heavy lifting;
if it says this text in this font takes up this many pixels, that's
how many pixels of width I allocate it. RTL? LTR? Mixed? No problem.
It'll do all that for me.

So yeah. Unicode isn't a panacea, and if you come from an ASCII-only
environment, Unicode will look hard - but it's making life far easier
than the alternatives would be.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Text-mode apps (Was :Who are the "spacists"?)

2017-03-26 Thread Chris Angelico
On Mon, Mar 27, 2017 at 5:10 AM, Steve D'Aprano
 wrote:
>> And for own standalone app, I would not use any TTF or
>> anything vector-based font, since why?
>
> Right, because your users will *love* to see their native language displayed
> in a crappy bitmapped font with jagged or blurry edges.

Side point: I have spent many hours wrestling with VLC to try to get a
subtitles font that looks good for all the world's languages. My
current setup has Latin, Cyrillic, and Greek looking great, Hebrew and
Arabic looking adequate (I'm no expert so I don't know beyond that),
but Thai, Chinese, Japanese, and Korean characters have jagged edges.
Thanks guys. It's 2017 and we're still using bitmap fonts.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


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.com/doc/refman/5.7/en/update.html for Update
>> > statement syntax.
>
> I cannot understand where the error is.
> Could you how it to me please?

Are people paying you to run their servers, and you're not even
prepared to spend a few minutes reading the documentation before
firing another post to a newsgroup/mailing list with thousands of
participants? (Actually, I have no idea how many people read
python-list/clp - 10K? 100K? 1M?)

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Text-mode apps (Was :Who are the "spacists"?)

2017-03-26 Thread eryk sun
On Sun, Mar 26, 2017 at 5:58 PM, Chris Angelico  wrote:
>> The Windows console can render any character in the BMP, but it
>> requires configuring font linking for fallback fonts. It's Windows, so
>> of course the supported UTF format is UTF-16. The console's UTF-8
>> support (codepage 65001) is too buggy to even consider using it.
>
> Is it actually UTF-16, or is it UCS-2?

Pedantically speaking it's UCS-2. Console buffers aren't necessarily
valid UTF-16, i.e. they can have lone surrogate codes or invalid
surrogate pairs. The way a surrogate code gets rendered depends on the
font. It could be an empty box, a box containing a question mark, or
simply empty space. That applies even if it's a valid UTF-16 surrogate
pair, so the console can't display non-BMP characters such as emojis.
They can be copied to the clipboard and displayed in another program.

Windows file systems are also UCS-2. For the most part it's not an
issue since the source of text and filenames will be valid UTF-16.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Text-mode apps (Was :Who are the "spacists"?)

2017-03-26 Thread eryk sun
On Sun, Mar 26, 2017 at 5:49 PM, eryk sun  wrote:
> On Sun, Mar 26, 2017 at 5:29 PM, Chris Angelico  wrote:
>> Rounded corners?
>>
>> ╭─┬─╮
>> ├─┼─┤
>> ╰─┴─╯
>
> This prints fine in the Windows console with Consolas as the font, but
> the older Courier New and Lucida Console fonts lack glyphs for the
> rounded corners.

I configured Consolas as a fallback for Lucida Console, and now it
shows the rounded corners in the console, but it beats me why anyone
would do that instead of simply using Consolas.
-- 
https://mail.python.org/mailman/listinfo/python-list


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 
> >> 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 is all i get form error. error_log doesnt produce errors when iam 
> >> trying
> >>
> >> 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, domain, ref, 
> >> location, useros, browser, lastvisit, domain) )
> >>
> >> WHY the valued aren't getting substituted wi the aeguments i give it in to 
> >> work with?
> >
> > The % construct is Python 2 and no longer supported in Python 3. You should 
> > read up on the "{}" and format method.
> >
> > https://docs.python.org/3/tutorial/inputoutput.html#fancier-output-formatting
> 
> Rubbish, it works just fine in Python 3:
> 
> Python 3.6.0 (default, Jan  1 2017, 22:51:19)
> [GCC 5.4.0 20160609] on linux
> Type "help", "copyright", "credits" or "license" for more information.
> >>> '%s %s' % ('Hello', 'world')
> 'Hello world'
> 
> And contrary to popular belief, it's not even deprecated (although use
> of the newer format method is encouraged). What's more, in this case
> it's part of the PEP 249 DBAPI specification:
> https://www.python.org/dev/peps/pep-0249/#paramstyle. As far as I know
> pymysql and DBAPI libraries in general don't even accept "{}".

There was quite a chat about the issue of deprecated or not 
http://www.gossamer-threads.com/lists/python/dev/969817

Kindest regards.

Mark Lawrence.
-- 
https://mail.python.org/mailman/listinfo/python-list


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 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.
> >
> > I cannot understand where the error is.
> > Could you how it to me please?
> 
> Are people paying you to run their servers, and you're not even
> prepared to spend a few minutes reading the documentation before
> firing another post to a newsgroup/mailing list with thousands of
> participants? (Actually, I have no idea how many people read
> python-list/clp - 10K? 100K? 1M?)
> 
> ChrisA

So the answer is within that url link and i cannot see it?!

Give me a hint!
-- 
https://mail.python.org/mailman/listinfo/python-list


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:
> >> 
> >> > Τη Κυριακή, 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) VALUES (%s, %s, %s, %s, %s, %s, %s) WHERE
> >> > host LIKE "%%s%" ''',
> >> > 
> >> > 
> >> (pID, domain, ref, location, useros,
> >> > 
> >> > 
> >> browser, lastvisit, domain) )
> >> > 
> >> > but now the problem is how to exact;y type the Where HOST like "%%%"
> >> > 
> >> > I MEAN HOW TO DIFFERENTIATE '%S' FROM LITERAL '%' character.
> >> 
> >> 
> >> as a quick thought (untested) it is probably best to have %s as your
> >> parameter for the Like clause & ad the sql wild-cards (% symbols) to
> >> the data you pass in as I think the expansion of %s adds quote marks
> >> which will certainly cause the sql parser issues.
> > 
> > How do you propose writing that cur.execute statement Alister?
> 
> 
> cur.execute('''UPDATE visitors SET (pagesID, host, ref, location,
> >> > useros, browser, visits) VALUES (%s, %s, %s, %s, %s, %s, %s) WHERE
> >> > host LIKE %s '''
> 
> but you will need to amend the data  you pass so that the last element 
> has the surrounding % characters .
> 
> 
> -- 
> T-1's congested due to porn traffic to the news server.

i have done so ith 3 different ways to prepare the string before sending it as 
an argument to update query as i mentioned in a previous post.

Unfortunately all 3 ways weren't able to make the query work.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Text-mode apps (Was :Who are the "spacists"?)

2017-03-26 Thread Chris Angelico
On Mon, Mar 27, 2017 at 5:37 AM, eryk sun  wrote:
> On Sun, Mar 26, 2017 at 5:58 PM, Chris Angelico  wrote:
>>> The Windows console can render any character in the BMP, but it
>>> requires configuring font linking for fallback fonts. It's Windows, so
>>> of course the supported UTF format is UTF-16. The console's UTF-8
>>> support (codepage 65001) is too buggy to even consider using it.
>>
>> Is it actually UTF-16, or is it UCS-2?
>
> Pedantically speaking it's UCS-2. Console buffers aren't necessarily
> valid UTF-16, i.e. they can have lone surrogate codes or invalid
> surrogate pairs. The way a surrogate code gets rendered depends on the
> font. It could be an empty box, a box containing a question mark, or
> simply empty space. That applies even if it's a valid UTF-16 surrogate
> pair, so the console can't display non-BMP characters such as emojis.
> They can be copied to the clipboard and displayed in another program.

Exactly. So it's not supporting the entire Unicode range, but only the
BMP. That restricts its usability for anything other than simple text.

> Windows file systems are also UCS-2. For the most part it's not an
> issue since the source of text and filenames will be valid UTF-16.

I'm actually not sure on that one. Poking around on both Stack
Overflow and MSDN suggests that NTFS does actually use UTF-16, which
implies that lone surrogates should be errors, but I haven't proven
this. In any case, file system encoding is relatively immaterial; it's
file system *API* encoding that matters, and that means the
CreateFileW function and its friends:

https://msdn.microsoft.com/en-us/library/windows/desktop/aa363858(v=vs.85).aspx
https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx
https://msdn.microsoft.com/en-us/library/gg269344(v=exchg.10).aspx

My reading of this is that:

a) The API is defined in terms of the WCHAR type, a 16-bit code unit.
b) Limits are described in terms of "characters" (eg a max of 32767
for a path that starts "\\?\")
c) ???
d) Profit??

I *think* it's the naive (and very common) hybrid of UCS-2 and UTF-16
that says "surrogates are allowed anywhere, and you're allowed to
interpret pairs of them as UTF-16". But that's not a standard
encoding. In actual UCS-2, surrogates are entirely disallowed; in
UTF-16, they *must* be correctly paired.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


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 
>> > έγραψε:
>> >> 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.
>> >
>> > I cannot understand where the error is.
>> > Could you how it to me please?
>>
>> Are people paying you to run their servers, and you're not even
>> prepared to spend a few minutes reading the documentation before
>> firing another post to a newsgroup/mailing list with thousands of
>> participants? (Actually, I have no idea how many people read
>> python-list/clp - 10K? 100K? 1M?)
>>
>> ChrisA
>
> So the answer is within that url link and i cannot see it?!
>
> Give me a hint!

You cannot see it? Why not - are you unable to access the web? Then
track down the equivalent local documentation. I don't have MySQL or
MariaDB installed here, but with PostgreSQL, I can fire up the CLI and
get documentation on SQL commands.

So no, I won't give you a hint until you get a clue.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


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:
> >> > Τη Κυριακή, 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 syntax.
> >> >
> >> > I cannot understand where the error is.
> >> > Could you how it to me please?
> >>
> >> Are people paying you to run their servers, and you're not even
> >> prepared to spend a few minutes reading the documentation before
> >> firing another post to a newsgroup/mailing list with thousands of
> >> participants? (Actually, I have no idea how many people read
> >> python-list/clp - 10K? 100K? 1M?)
> >>
> >> ChrisA
> >
> > So the answer is within that url link and i cannot see it?!
> >
> > Give me a hint!
> 
> You cannot see it? Why not - are you unable to access the web? Then
> track down the equivalent local documentation. I don't have MySQL or
> MariaDB installed here, but with PostgreSQL, I can fire up the CLI and
> get documentation on SQL commands.
> 
> So no, I won't give you a hint until you get a clue.
> 
> ChrisA

I can see it Chris, but i just cannot "see" it.

If i remove the WHERE LIKE clause statement executes properly.

Its when adding the clause that does not interpolated correctly.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Text-mode apps (Was :Who are the "spacists"?)

2017-03-26 Thread Mikhail V
On 26 March 2017 at 20:10, Steve D'Aprano  wrote:
> On Mon, 27 Mar 2017 03:57 am, Mikhail V wrote:
>
> [...]
 And more important: can one use binary (bitmap) fonts in default modern
 linux console? If yes, can one patch them with custom tiles at
 the application start?
>>>
>>> If you really need something completely custom, it's not text any
>>> more.
>>
>> Obvious fact, but if I need e.g. rounded corners in table drawing
>> characters? Or I just want to fix some characters which look especially
>> ugly? Create a new TTF? No, thanks, this would be worst nightmare to
>> do without a special tool (which have prices with several zeros, otherwise
>> just don't work and can even break things system-wide)
>
> Don't be silly. It took me ten seconds on Google to find this:
>
> https://birdfont.org/
>

It takes you ten seconds to Google, and what if I ask you
to take, say Courier New font TTF file (which includes not only
vector information but all that is responsible for bitmap
rendering, subpixeling, etc), then edit one character (and
all corresponding information for subpixeling),
then compile it as a new font, then install it on Win,
without that making any conflicts, and without _any_
further glitches or changes in other characters, and no such
things across all applications.
If you'd try that, and you will succeed, _then_ I will publicly admit
that I was silly.

And paying even 50$ for correcting one glyph... well
probably I'll do it if one gives guarantee that all above
will work.

>
>>> More likely, you don't truly need something custom - what you need is
>>> a different subset of characters (maybe you need to mix Latin, Greek,
>>> and Hebrew letters, in order to show interlinear translation of the
>>> Bible). Instead of messing around with character sets, you can just
>>> use Unicode and have all of them available.
>>
>> If I was to deal with multiple language charsets in _my own_ rendering
>> app, I would still use discrete encoding for inner algorithms.
>> i.e. I would place separate charsets on separate code ranges.
>
> Why? Because you think you know better than the thousands of professionals
> who have worked with text formats for decades?

Sounds provocative, but yes, in some cases I know what I am
doing ;-).
But that is not because professionals does not know,
there are many other aspects which come in play here.
It depends on the use case, Unicode solves only some
problems.
I was talking only about _my own_ usage, it
will be obviously incompatible e.g. for copy-pasting
between othr apps.
There are benefits to store language-specific values (+ their glyphs)
in separate stacks.
Anyway this discussion will require concrete
examples and much deeper investigation.

>
>> And for own standalone app, I would not use any TTF or
>> anything vector-based font, since why?
>
> Right, because your users will *love* to see their native language displayed
> in a crappy bitmapped font with jagged or blurry edges.
>

I am working on text rendering algorithms an have prototyped
several bitmap-based text rendering algorithms,
both managed and prerendered approaches, and there
is _nothing_ jagged or [incorrectly] blurred there, when
one knows what he's doing of course.
So it would be _very_ hard to catch me on incompetence
here, but you can try, and feel free to do it :

FYI vector-based fonts were mainly motivated by print design.
Modern GPUs have capabilities for fast vector
glyph rendering, but it is not needed for screen rendering,
much less when higher DPI displays will prevale.

Mikhail
-- 
https://mail.python.org/mailman/listinfo/python-list


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 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 '%%%s%%' % domain or '%{}%'.format(domain).
> > 
> > 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" 
> > ''', 
> > 
> > 
> > 
> > (pID, domain, ref, 
> > location, useros, browser, lastvisit, domain) )
> > 
> > 
> > and i received no error in the error_log but
> > 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")
> > 
> > which you can see at http://superhost.gr
> > 
> > You said somethign about concatenating the literal % in the SQL to which i 
> > didnt actually i understand how to implement.
> 
> I knew that I had a sense of deja vu about this 
> https://mail.python.org/pipermail/python-list/2013-June/649809.html
> 
> Kindest regards.
> 
> Mark Lawrence

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.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Text-mode apps (Was :Who are the "spacists"?)

2017-03-26 Thread Chris Angelico
On Mon, Mar 27, 2017 at 6:25 AM, Mikhail V  wrote:
> On 26 March 2017 at 20:10, Steve D'Aprano  wrote:
>> On Mon, 27 Mar 2017 03:57 am, Mikhail V wrote:
>>
>> [...]
> And more important: can one use binary (bitmap) fonts in default modern
> linux console? If yes, can one patch them with custom tiles at
> the application start?

 If you really need something completely custom, it's not text any
 more.
>>>
>>> Obvious fact, but if I need e.g. rounded corners in table drawing
>>> characters? Or I just want to fix some characters which look especially
>>> ugly? Create a new TTF? No, thanks, this would be worst nightmare to
>>> do without a special tool (which have prices with several zeros, otherwise
>>> just don't work and can even break things system-wide)
>>
>> Don't be silly. It took me ten seconds on Google to find this:
>>
>> https://birdfont.org/
>>
>
> It takes you ten seconds to Google, and what if I ask you
> to take, say Courier New font TTF file (which includes not only
> vector information but all that is responsible for bitmap
> rendering, subpixeling, etc), then edit one character (and
> all corresponding information for subpixeling),
> then compile it as a new font, then install it on Win,
> without that making any conflicts, and without _any_
> further glitches or changes in other characters, and no such
> things across all applications.
> If you'd try that, and you will succeed, _then_ I will publicly admit
> that I was silly.
>
> And paying even 50$ for correcting one glyph... well
> probably I'll do it if one gives guarantee that all above
> will work.

See previous comments about font substitution. Create a font with just
one character in it. Use that font in your application. Voila! No
changes to any other applications (because they'll still be using the
original font), and no changes to any other characters.

However, I'm impressed that you found a bug in a well-used font.

http://www.catb.org/esr/faqs/smart-questions.html#idm46227256017920

Is it that decades of typographical research is incorrect, or that the
designers of this font just sucked? You're pretty unambiguous in your
description that you are "correcting" a glyph. Not adapting it to your
own purposes - you're correcting something that's fundamentally wrong
in someone else's font. Impressive.

>> Why? Because you think you know better than the thousands of professionals
>> who have worked with text formats for decades?
>
> Sounds provocative, but yes, in some cases I know what I am
> doing ;-).
> But that is not because professionals does not know,
> there are many other aspects which come in play here.
> It depends on the use case, Unicode solves only some
> problems.
> I was talking only about _my own_ usage, it
> will be obviously incompatible e.g. for copy-pasting
> between othr apps.
> There are benefits to store language-specific values (+ their glyphs)
> in separate stacks.
> Anyway this discussion will require concrete
> examples and much deeper investigation.

I generally find that when people say that Unicode doesn't solve their
problems and they need to roll their own, it's usually one of two
possibilities:

1) "Their problems" are all about simplicity. They don't want to have
to deal with all the complexities of real-world text, so they
arbitrarily restrict things.
2) Unicode _would_ solve their problems, they just don't realize it.

So if you're rolling your own text display system, you should start by
making a signed declaration:

"""
I, the undersigned, acknowledge that my program is intentionally
excluding everyone who does not fit the following requirements:
[choose all applicable]

[ ] Speaks English exclusively
[ ] Uses no diacritical marks
[ ] Writes all text top-to-bottom, left-to-right
[ ] Uses only characters from the Basic Multilingual Plane
[ ] Uses only characters from this codepage: 
[ ] Uses a monospaced font
[ ] Uses a proportionally-spaced font
[ ] Uses this font: _
[ ] Uses a mouse
[ ] Uses a keyboard
[ ] Other: ___
(use additional pages if required)

Signed: ___
"""

Sure, there are good reasons to place restrictions on people's text.
But those restrictions are part of your public API and UI. Acknowledge
them. Own them. And justify them.

>>> And for own standalone app, I would not use any TTF or
>>> anything vector-based font, since why?
>>
>> Right, because your users will *love* to see their native language displayed
>> in a crappy bitmapped font with jagged or blurry edges.
>>
>
> I am working on text rendering algorithms an have prototyped
> several bitmap-based text rendering algorithms,
> both managed and prerendered approaches, and there
> is _nothing_ jagged or [incorrectly] blurred there, when
> one knows what he's doing of course.
> So it would be _very_ hard to catch me on incompetence
> here, but you can try, and feel free to do it :

Sure. Render me two characters on a half-meter-wide 1920x1080 screen.
I'll cho

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 expertise, unless s/he is suffering from severe self-image
problems. Someone who's getting paid to host other people's web sites,
on the other hand, needs to solve the problems that come up.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


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 
> > me.
> 
> It's not his problem. An expert does not have to provide solutions to
> prove his expertise, unless s/he is suffering from severe self-image
> problems. Someone who's getting paid to host other people's web sites,
> on the other hand, needs to solve the problems that come up.
> 
> ChrisA

Okey although i beleive my UPDATE query to be correct i'll now 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) )
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread Νίκος Βέργος
Τη Κυριακή, 26 Μαρτίου 2017 - 11:05:34 μ.μ. UTC+3, ο χρήστης Νίκος Βέργος 
έγραψε:
> Τη Κυριακή, 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 me.
> > 
> > It's not his problem. An expert does not have to provide solutions to
> > prove his expertise, unless s/he is suffering from severe self-image
> > problems. Someone who's getting paid to host other people's web sites,
> > on the other hand, needs to solve the problems that come up.
> > 
> > ChrisA
> 
> Okey although i beleive my UPDATE query to be correct i'll now 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 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

OMG!!!
-- 
https://mail.python.org/mailman/listinfo/python-list


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 (pagesID, host, ref, location, useros, browser, visits) VALUES (%s, 
%s, %s, %s, %s, %s, %s) WHERE host LIKE "%s" (1, 'cyta.gr', 'Άμεση Πρόσβαση', 
'Greece', 'Windows', 'Chrome', '17-03-24 22:04:24', 'cyta.gr')

How should i write the cursor.execute in order to be parsed properly?
As i have it now %s does not get substituted.


You don't get the substitution because you're missing a %.

Change:
... LIKE "%s"''', (pID, ...
To:
... LIKE "%s"''' % (pID, ...

--
 -=- Larry -=-
--
https://mail.python.org/mailman/listinfo/python-list


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, domain, ref, location, useros, browser, lastvisit, domain) )
> >
> > prints out:
> >
> > UPDATE visitors SET (pagesID, host, ref, location, useros, browser, visits) 
> > VALUES (%s, %s, %s, %s, %s, %s, %s) WHERE host LIKE "%s" (1, 'cyta.gr', 
> > 'Άμεση Πρόσβαση', 'Greece', 'Windows', 'Chrome', '17-03-24 22:04:24', 
> > 'cyta.gr')
> >
> > How should i write the cursor.execute in order to be parsed properly?
> > As i have it now %s does not get substituted.
> 
> You don't get the substitution because you're missing a %.
> 
> Change:
>  ... LIKE "%s"''', (pID, ...
> To:
>  ... LIKE "%s"''' % (pID, ...
> 
> -- 
>   -=- Larry -=-

No, i have tried it many times. 
It fails and is prone to sql injection within a cursor execute.

As i understood i can have UPDATE syntax be as similar to INSERT like

(pagesID, host, ref, location, useros, browser, visits) VALUES (%s, %s, %s, %s, 
%s, %s, %s)

each column needs to be set respectively as column1 = value1, column2 = value 2 
and so on.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Text-mode apps (Was :Who are the "spacists"?)

2017-03-26 Thread eryk sun
On Sun, Mar 26, 2017 at 6:57 PM, Chris Angelico  wrote:
>
> In actual UCS-2, surrogates are entirely disallowed; in UTF-16, they *must* be
> correctly paired.

Strictly-speaking UCS-2 disallows codes that aren't defined by the
standard, but the kernel couldn't be that restrictive. Unicode was a
moving target in the period that NT was developed (1988-93). The
object manager simply allows any 16-bit code in object names, except
its path separator, backslash. Since a UNICODE_STRING is counted, even
NUL is allowed in object names. But that's uncommon and should be
avoided since the user-mode API uses null-terminated strings.

The file-system runtime library further restricts this by reserving
NUL, ASCII control codes, forward slash, pipe, and the wildcard
characters asterisk, question mark, double quote, less than, and
greater than. The rules are loosened for NTFS named streams, which
only reserve NUL, forward slash, and backslash.

>> Windows file systems are also UCS-2. For the most part it's not an
>> issue since the source of text and filenames will be valid UTF-16.
>
> I'm actually not sure on that one. Poking around on both Stack
> Overflow and MSDN suggests that NTFS does actually use UTF-16, which
> implies that lone surrogates should be errors, but I haven't proven
> this. In any case, file system encoding is relatively immaterial; it's
> file system *API* encoding that matters, and that means the
> CreateFileW function and its friends:

Sure, the file system itself can use any encoding, but Microsoft use a
permissive UCS-2 in its file systems. The API uses 16-bit WCHARs, and
except for a relatively small set of codes (assuming it uses the
FsRtl), the system generally doesn't care about the values. Let's
review the major actors.

CreateFile uses the runtime library in ntdll.dll to fill in an
OBJECT_ATTRIBUTES [1] with a UNICODE_STRING [2]. This is where the
current-directory handle is set as the attributes RootDirectory handle
for relative paths; where slash is replaced with backslash; and where
weird MS-DOS rules are applied, such as DOS device names and trimming
trailing spaces. Once it has a native object attributes record, it
calls the real system call NtCreateFile [3]. In kernel mode this in
turn calls the I/O manager function IoCreateFile [4], which creates an
open packet and calls the object manger function ObOpenObjectByName.

Now it's time for path parsing. In the normal case the system
traverses several object directories and object symbolic links before
finally arriving at an I/O device (e.g. \??\C: => \Global??\C: =>
\Device\HarddiskVolume2). Parsing the rest of the path is in the hands
of the I/O manager via the Device object's ParseProcedure. The I/O
manager creates a File object and an I/O request packet (IRP) for the
major function IRP_MJ_CREATE [5] and calls the driver for the device
stack via IoCallDriver [6]. If the device is a volume that's managed
by a file-system driver (e.g. ntfs.sys), the file-system parses the
remaining path to open or create the directory/file/stream and
complete the IRP. The object manager creates a handle for the File
object in the handle table of the calling process, and this handle
value is finally passed back to the caller.

[1]: https://msdn.microsoft.com/en-us/library/ff557749
[2]: https://msdn.microsoft.com/en-us/library/ff564879
[3]: https://msdn.microsoft.com/en-us/library/ff566424
[4]: https://msdn.microsoft.com/en-us/library/ff548418
[5]: https://msdn.microsoft.com/en-us/library/ff548630
[6]: https://msdn.microsoft.com/en-us/library/ff548336

The object manager only cares about its path separator, backslash,
until it arrives at an object type that it doesn't manage, such as a
Device object. If a file system uses the FsRtl, then the remaining
path is subject to Windows file-system rules. It would be ill-advised
to diverge from these rules.

> I *think* it's the naive (and very common) hybrid of UCS-2 and UTF-16

It's just the way the system evolved over time. UTF-16 wasn't
standardized until 1996 circa NT 4.0. Windows started integrating it
around NT 5 (Windows 2000), primarily for the GUI controls in the
windowing system that directly affect text processing for most
applications. It was good enough to leave most of the lower layers of
the system passively naive when it comes to UTF-16.
-- 
https://mail.python.org/mailman/listinfo/python-list


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 add them to the string before you pass it in, i.e. '%' + domain +
> > '%' or '%%%s%%' % domain or '%{}%'.format(domain).
> 
> 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" 
> ''', 
>   
>   
>   
> (pID, domain, ref, location, 
> useros, browser, lastvisit, domain) )
> 
> 
> and i received no error in the error_log but
> 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")
> 
> which you can see at http://superhost.gr
> 
> You said somethign about concatenating the literal % in the SQL to which i 
> didnt actually i understand how to implement.

I knew that I had a sense of deja vu about this 
https://mail.python.org/pipermail/python-list/2013-June/649809.html

Kindest regards.

Mark Lawrence
-- 
https://mail.python.org/mailman/listinfo/python-list


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, ο χρήστης 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 '%%%s%%' % domain or '%{}%'.format(domain).
> > > 
> > > 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" 
> > > ''', 
> > >   
> > >   
> > >   
> > > (pID, domain, ref, 
> > > location, useros, browser, lastvisit, domain) )
> > > 
> > > 
> > > and i received no error in the error_log but
> > > 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")
> > > 
> > > which you can see at http://superhost.gr
> > > 
> > > You said somethign about concatenating the literal % in the SQL to which 
> > > i didnt actually i understand how to implement.
> > 
> > I knew that I had a sense of deja vu about this 
> > https://mail.python.org/pipermail/python-list/2013-June/649809.html
> > 
> > Kindest regards.
> > 
> > Mark Lawrence
> 
> 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.

*plonk*
-- 
https://mail.python.org/mailman/listinfo/python-list


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);
Query OK, 1 row affected (0.00 sec)

mysql> update test_update set (b, c) values (4, 5) where a = 1;
ERROR 1064 (42000): You have an error in your SQL syntax; check the
manual that corresponds to your MySQL server version for the right
syntax to use near '(b, c) values (4, 5) where a = 1' at line 1

mysql> update test_update set b=4, c=5 where a = 1;
Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0

>
> It's just when the LIKE clause jumps in that is causing all this trouble

Your MariaDB said:

> check the manual that corresponds to your MariaDB server version for the 
> right syntax to use near '(pagesID, host, ...

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?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Text-mode apps (Was :Who are the "spacists"?)

2017-03-26 Thread Mikhail V
On 26 March 2017 at 21:53, Chris Angelico  wrote:
> On Mon, Mar 27, 2017 at 6:25 AM, Mikhail V  wrote:
>> On 26 March 2017 at 20:10, Steve D'Aprano  wrote:
>>> On Mon, 27 Mar 2017 03:57 am, Mikhail V wrote:
>>>
>>> [...]
>> And more important: can one use binary (bitmap) fonts in default modern
>> linux console? If yes, can one patch them with custom tiles at
>> the application start?
>
> If you really need something completely custom, it's not text any
> more.

 Obvious fact, but if I need e.g. rounded corners in table drawing
 characters? Or I just want to fix some characters which look especially
 ugly? Create a new TTF? No, thanks, this would be worst nightmare to
 do without a special tool (which have prices with several zeros, otherwise
 just don't work and can even break things system-wide)
>>>
>>> Don't be silly. It took me ten seconds on Google to find this:
>>>
>>> https://birdfont.org/
>>>
>>
>> It takes you ten seconds to Google, and what if I ask you
>> to take, say Courier New font TTF file (which includes not only
>> vector information but all that is responsible for bitmap
>> rendering, subpixeling, etc), then edit one character (and
>> all corresponding information for subpixeling),
>> then compile it as a new font, then install it on Win,
>> without that making any conflicts, and without _any_
>> further glitches or changes in other characters, and no such
>> things across all applications.
>> If you'd try that, and you will succeed, _then_ I will publicly admit
>> that I was silly.
>>
>> And paying even 50$ for correcting one glyph... well
>> probably I'll do it if one gives guarantee that all above
>> will work.
>
> See previous comments about font substitution. Create a font with just
> one character in it. Use that font in your application. Voila! No
> changes to any other applications (because they'll still be using the
> original font), and no changes to any other characters.

Good tip, I'll try that. Though still one need an app, even
for one character, and it'll need fallback setup on each
computer I use.
Dont get it wrong, I don't say it is impossible. There are
guys that have figured out such things and I've read once
something about hacking bitmap and subpixeling
information directly in the font file, but I was not
stubborn enough to learn that.


> Is it that decades of typographical research is incorrect, or that the
> designers of this font just sucked? You're pretty unambiguous in your
> description that you are "correcting" a glyph. Not adapting it to your
> own purposes - you're correcting something that's fundamentally wrong
> in someone else's font. Impressive.

Call it "modify for own purpose" if it sounds better.
In Courier, the brackets are too small, tilde char is too
much like hyphen, some other minor things.
And Courier New bold is best readable (for me ;) font on Win
 so I don't want another font, which has better brackets,
but less readable. And as said, if possible I avoid
monospaced font where possible, so this means
that probably I'll need to modfy some other fonts too.


 And for own standalone app, I would not use any TTF or
 anything vector-based font, since why?
>>>
>>> Right, because your users will *love* to see their native language displayed
>>> in a crappy bitmapped font with jagged or blurry edges.
>>>
>>
>> I am working on text rendering algorithms an have prototyped
>> several bitmap-based text rendering algorithms,
>> both managed and prerendered approaches, and there
>> is _nothing_ jagged or [incorrectly] blurred there, when
>> one knows what he's doing of course.
>> So it would be _very_ hard to catch me on incompetence
>> here, but you can try, and feel free to do it :
>
> Sure. Render me two characters on a half-meter-wide 1920x1080 screen.
> I'll choose the exact size dynamically, at run-time, in response to
> the amount of chrome I have on the window. Make sure the two
> characters look perfect whether I make this a tiny marker on the
> screen, or make it completely fill the entire monitor.
> [...]
> Even if high-DPI displays *do* prevail, you still have to render
> text at a wide variety of pixel sizes.

Seems like you are jumping from one corner case to another.
In general, if you want huge letters or some design tasks
(e.g. huge letters for a print) you can use vector paths.
But remember that a photo or a bitmap texture will not
become new information if you convert each pixel to a vector square, or
circle.  It is only question of scalability.

Concentrate on these points:
- Restrict the case to display only
- Making one letter fill half of a monitor, or rotating it arbitrary,
has little to do with reading text on a monitor in real situation.
- Your understanding of "look perfect" and relation with
information cognition (e.g. a retro game upscaled with
integer scaler versus a remake of this game made completely
with higher resolution sprites - will you say
that the latter feels

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 told you, over and over and over again:

READ THE MANUAL.

The error message told you it was a SQL syntax error, but no, you insisted
that you knew better, and refused to do what the error message said.

So you wasted three days due to your own stubbornness and laziness.

I have no sympathy for your self-inflicted problems.




-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Text-mode apps (Was :Who are the "spacists"?)

2017-03-26 Thread Tim Chase
On 2017-03-27 02:37, Chris Angelico wrote:
> > In DOS, (I don't remember if in all versions or only some)
> > one could do all this and this opens very rich possibilities for
> > approximating of objects with tiles. The only limitations
> > that one uses 255 tiles, but even this enables to build
> > whole 'worlds' and state of the art apps. So I would call this
> > pseudographics and not few sticks and corner tiles
> > (which I cannot even define and upload easily).  
> 
> Yeah; if my memory serves me, this was an IBM BIOS feature, so all
> versions of DOS would be equally able to do it. But it's basically a
> form of tile graphics, not text. 

It was a function of the EGA/VGA card (maybe CGA? Though I think
that might have been limited to the upper 128 chars while the lower
128 were fixed), not the IBM BIOS.  But yes, there were font-editors
for the EGA/VGA fonts and, once set, they'd appear even in things
like WordPerfect, QuattroPro, Lotus, or Turbo Pascal.  All the rage
back in my 286-wolfenstein3d-playing-turbopascal-programming days. ;-)

-tkc


-- 
https://mail.python.org/mailman/listinfo/python-list


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);
> Query OK, 0 rows affected (0.02 sec)
> 
> mysql> insert into test_update values (1, 2, 3);
> Query OK, 1 row affected (0.00 sec)
> 
> mysql> update test_update set (b, c) values (4, 5) where a = 1;
> ERROR 1064 (42000): You have an error in your SQL syntax; check the
> manual that corresponds to your MySQL server version for the right
> syntax to use near '(b, c) values (4, 5) where a = 1' at line 1
> 
> mysql> update test_update set b=4, c=5 where a = 1;
> Query OK, 1 row affected (0.01 sec)
> Rows matched: 1  Changed: 1  Warnings: 0
> 
> >
> > It's just when the LIKE clause jumps in that is causing all this trouble
> 
> Your MariaDB said:
> 
> > check the manual that corresponds to your MariaDB server version for the 
> > right syntax to use near '(pagesID, host, ...
> 
> 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 INSERT and i was persistent 
that the WHERE LIKE clause was cauing this.

I'am still surprised that:
> mysql> update test_update set (b, c) values (4, 5) where a = 1;

is failign to parse. It just seems so undoubtly straightforward and correct 
syntactically.
-- 
https://mail.python.org/mailman/listinfo/python-list


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 INSERT and i was persistent 
> that the WHERE LIKE clause was cauing this.
>
> I'am still surprised that:
>> mysql> update test_update set (b, c) values (4, 5) where a = 1;
>
> is failign to parse. It just seems so undoubtly straightforward and correct 
> syntactically.

So when people told you to read the docs, what did you do, exactly?

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


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 problem for this issue?
> >
> > Yes indeed it is.
> > I was just so sure that UPDATE was working like INSERT and i was persistent 
> > that the WHERE LIKE clause was cauing this.
> >
> > I'am still surprised that:
> >> mysql> update test_update set (b, c) values (4, 5) where a = 1;
> >
> > is failign to parse. It just seems so undoubtly straightforward and correct 
> > syntactically.
> 
> So when people told you to read the docs, what did you do, exactly?
> 
> ChrisA

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 to me over the other one.

UPDATE visitors SET (pagesID, host, ref, location, useros, browser, visits) 
VALUES (%s, %s, %s, %s, %s, %s, %s) WHERE host LIKE "%s"

Its still a mystery to em whay this fails syntactically when at the same time 
INSERT works like that.

We give each columnn a specific value i don't see why it must only be written 
as UPDATE visitors SET a=1, b=2, c=3 ... WHERE host LIKE %s.

i knew that would work, but the first way although proven syntactically wrong 
seems so right .
-- 
https://mail.python.org/mailman/listinfo/python-list


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 to me over the other one.
>
> UPDATE visitors SET (pagesID, host, ref, location, useros, browser, visits) 
> VALUES (%s, %s, %s, %s, %s, %s, %s) WHERE host LIKE "%s"
>
> Its still a mystery to em whay this fails syntactically when at the same time 
> INSERT works like that.
>
> We give each columnn a specific value i don't see why it must only be written 
> as UPDATE visitors SET a=1, b=2, c=3 ... WHERE host LIKE %s.
>
> i knew that would work, but the first way although proven syntactically wrong 
> seems so right .

It'd be even more logical to write:

UPDATE visitors INCREMENT visits WHERE host CONTAINS %s;

I should just use that syntax, and if it doesn't work, I'm going to
post onto a mailing list until it magically starts working. It's NOT
that I haven't read the docs - I'm just going to wilfully ignore them.

Okay, I'm done now.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


RE: [Python-ideas] Proposal: Query language extension to Python (PythonQL)

2017-03-26 Thread Gerald Britton
(Forgot the subject)


> >* On 25 Mar 2017, at 15:51, Gerald Britton  >> wrote:
> *> >* On 25 March 2017 at 11:24, Pavel Velikhov   >> wrote:
> *>* > No, the current solution is temporary because we just don’t have the
> *>* > manpower to
> *>* > implement the full thing: a real system that will rewrite parts of 
> PythonQL
> *>* > queries and
> *>* > ship them to underlying databases. We need a real query optimizer and 
> smart
> *>* > wrappers
> *>* > for this purpose. But we’ll build one of these for demo purposes soon
> *>* > (either a Spark
> *>* > wrapper or a PostgreSQL wrapper).
> *>* One thought, if you're lacking in manpower now, then proposing
> *>* inclusion into core Python means that the core dev team will be taking
> *>* on an additional chunk of code that is already under-resourced. That
> *>* rings alarm bells for me - how would you imagine the work needed to
> *>* merge PythonQL into the core Python grammar would be resourced?
> *>* I should say that in practice, I think that the solution is relatively
> *>* niche, and overlaps quite significantly with existing Python features,
> *>* so I don't really see a compelling case for inclusion. The parallel
> *>* with C# and LINQ is interesting here - LINQ is a pretty cool
> *>* technology, but I don't see it in widespread use in general-purpose C#
> *>* projects (disclaimer: I don't get to see much C# code, so my
> *>* experience is limited).
> *> >* I see lots of C# code, but (thankfully) not so much LINQ to SQL.  Yes, 
> it is a cool technology.  But I sometimes have a problem with the SQL it 
> generates.  Since I'm also a SQL developer, I'm sensitive to how queries are 
> constructed, for performance reasons, as well as how they look, for 
> readability and aesthetic reasons.
> *> >* LINQ queries can generate poorly-performing SQL, since LINQ is a 
> basically a translator, but not an AI.  As far as appearances go, LINQ 
> queries can look pretty gnarly, especially if they include sub queries or a 
> few joins.  That makes it hard for the SQL dev (me!) to read and understand 
> if there are performance problems (which there often are, in my experience)
> *>

We want to go beyond being a basic translator. Especially if the
common use-case will be integrating multiple databases. We can also
introduce decent-looking hints (maybe not always decent looking) to
generate better plans. Not sure about asethetics though...

>* So, I would tend to code the SQL separately and put it in a SQL view, 
>function or stored procedure.  I can still parse the results with LINQ (not 
>LINQ to SQL), which is fine.
> *> >* For similar reasons, I'm not a huge fan of ORMs either.  Probably my 
> bias towards designing the database first and building up queries to meet the 
> business goals before writing a line of Python, C#, or the language de jour.
> *

This sounds completely reasonable, but this means you’re tied to a
specific DBMS (especially if you’re using a lot of built-in functions
that are usually very specific to a database). PythonQL (when it has
enough functionality) should give you independence.


True though not always needed.  e.g. at present I'm working for a large
company with thousands of db servers in all the popular flavors.  The
probability of changing even one of them to a different vendor is
essentially zero.  The costs and dependencies far outweigh any hoped-for
advantage.  At the same time, I'm happy to optimize the SQL for different
target environments.  If I lack the specific expertise, I know where to go
to find it.  The Adapter pattern helps here.

It's actually more important for me to build queries that can be used in
multiple client languages. We're using Java, C++, C#, F#, VB, ...  and
Python, of course (and probably others that I don't know we use). I can
optimize the query once and not worry about the clients messing it up.

-- 
Gerald Britton, MCSE-DP, MVP
LinkedIn Profile: http://ca.linkedin.com/in/geraldbritton
-- 
https://mail.python.org/mailman/listinfo/python-list


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 
> > was correctly and more consistent and similar to thr INSERT query and it 
> > was prefered to me over the other one.
> >
> > UPDATE visitors SET (pagesID, host, ref, location, useros, browser, visits) 
> > VALUES (%s, %s, %s, %s, %s, %s, %s) WHERE host LIKE "%s"
> >
> > Its still a mystery to em whay this fails syntactically when at the same 
> > time INSERT works like that.
> >
> > We give each columnn a specific value i don't see why it must only be 
> > written as UPDATE visitors SET a=1, b=2, c=3 ... WHERE host LIKE %s.
> >
> > i knew that would work, but the first way although proven syntactically 
> > wrong seems so right .
> 
> It'd be even more logical to write:
> 
> UPDATE visitors INCREMENT visits WHERE host CONTAINS %s;
> 
> I should just use that syntax, and if it doesn't work, I'm going to
> post onto a mailing list until it magically starts working. It's NOT
> that I haven't read the docs - I'm just going to wilfully ignore them.
> 
> Okay, I'm done now.
> 
> ChrisA

Okey i have taken my lesson.
I should have written it as the doc suggested instead of being persistent on 
finding what was worng in the way i had written it
-- 
https://mail.python.org/mailman/listinfo/python-list


pgcopy 1.2.0

2017-03-26 Thread altaurog
pgcopy 1.2.0 is now available!


pgcopy is a small utility for fast inserts to postgresql using binary copy.

features:
* Support for many datatypes
* Tested with python 2.7 and 3.3 - 3.6
* Works with postgresql versions 8.4 - 9.6
* Cache data on disk or in memory
* Supports explicit db schema
-- 
https://mail.python.org/mailman/listinfo/python-list