Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #41955 > unrolled thread
| Started by | Νίκος Γκρ33κ <nikos.gr33k@gmail.com> |
|---|---|
| First post | 2013-03-26 14:24 -0700 |
| Last post | 2013-03-27 19:17 -0700 |
| Articles | 20 on this page of 38 — 7 participants |
Back to article view | Back to comp.lang.python
MySQLdbd error. Perhpas it isn't installed? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-26 14:24 -0700
Re: MySQLdbd error. Perhpas it isn't installed? MRAB <python@mrabarnett.plus.com> - 2013-03-27 00:41 +0000
Re: MySQLdbd error. Perhpas it isn't installed? rurpy@yahoo.com - 2013-03-26 21:26 -0700
Re: MySQLdbd error. Perhpas it isn't installed? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-26 23:42 -0700
Re: MySQLdbd error. Perhpas it isn't installed? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-27 00:26 -0700
Re: MySQLdbd error. Perhpas it isn't installed? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-27 02:58 -0700
Re: MySQLdbd error. Perhpas it isn't installed? MRAB <python@mrabarnett.plus.com> - 2013-03-27 16:48 +0000
Re: MySQLdbd error. Perhpas it isn't installed? nagia.retsina@gmail.com - 2013-03-27 11:15 -0700
Re: MySQLdbd error. Perhpas it isn't installed? nagia.retsina@gmail.com - 2013-03-27 11:15 -0700
Re: MySQLdbd error. Perhpas it isn't installed? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-27 11:27 -0700
Re: MySQLdbd error. Perhpas it isn't installed? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-27 11:27 -0700
Re: MySQLdbd error. Perhpas it isn't installed? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-27 11:48 -0700
Re: MySQLdbd error. Perhpas it isn't installed? Joel Goldstick <joel.goldstick@gmail.com> - 2013-03-27 15:06 -0400
Re: MySQLdbd error. Perhpas it isn't installed? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-27 12:13 -0700
Re: MySQLdbd error. Perhpas it isn't installed? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-27 12:13 -0700
Re: MySQLdbd error. Perhpas it isn't installed? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-27 12:23 -0700
Re: MySQLdbd error. Perhpas it isn't installed? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-27 12:23 -0700
Re: MySQLdbd error. Perhpas it isn't installed? Chris Angelico <rosuav@gmail.com> - 2013-03-28 06:28 +1100
Re: MySQLdbd error. Perhpas it isn't installed? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-27 12:42 -0700
Re: MySQLdbd error. Perhpas it isn't installed? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-27 12:42 -0700
Re: MySQLdbd error. Perhpas it isn't installed? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-27 11:48 -0700
Re: MySQLdbd error. Perhpas it isn't installed? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-03-27 18:48 -0400
Re: MySQLdbd error. Perhpas it isn't installed? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-27 19:17 -0700
Re: MySQLdbd error. Perhpas it isn't installed? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-27 19:19 -0700
Re: MySQLdbd error. Perhpas it isn't installed? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-27 19:24 -0700
Re: MySQLdbd error. Perhpas it isn't installed? Chris Angelico <rosuav@gmail.com> - 2013-03-28 13:33 +1100
Re: MySQLdbd error. Perhpas it isn't installed? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-27 19:36 -0700
Re: MySQLdbd error. Perhpas it isn't installed? Chris Angelico <rosuav@gmail.com> - 2013-03-28 13:46 +1100
Re: MySQLdbd error. Perhpas it isn't installed? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-27 19:57 -0700
Re: MySQLdbd error. Perhpas it isn't installed? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-27 19:57 -0700
Re: MySQLdbd error. Perhpas it isn't installed? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-27 20:54 -0700
Re: MySQLdbd error. Perhpas it isn't installed? Chris Angelico <rosuav@gmail.com> - 2013-03-28 14:57 +1100
Re: MySQLdbd error. Perhpas it isn't installed? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-27 20:54 -0700
Re: MySQLdbd error. Perhpas it isn't installed? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-27 19:36 -0700
Re: MySQLdbd error. Perhpas it isn't installed? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-27 19:24 -0700
Re: MySQLdbd error. Perhpas it isn't installed? Chris Angelico <rosuav@gmail.com> - 2013-03-28 13:31 +1100
Re: MySQLdbd error. Perhpas it isn't installed? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-27 19:19 -0700
Re: MySQLdbd error. Perhpas it isn't installed? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-27 19:17 -0700
Page 1 of 2 [1] 2 Next page →
| From | Νίκος Γκρ33κ <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2013-03-26 14:24 -0700 |
| Subject | MySQLdbd error. Perhpas it isn't installed? |
| Message-ID | <f0bde519-61c9-4dfb-a097-48e348fd5c75@googlegroups.com> |
Hello today i deiced to go form python 2.6 to python 3.2.3
although in 2.6 my script runs in the ht enewest python i ge this error:
Traceback (most recent call last):
File "/opt/python3/lib/python3.2/site-packages/MySQL_python-1.2.3-py3.2-linux-x86_64.egg/MySQLdb/cursors.py", line 171, in execute
r = self._query(query)
File "/opt/python3/lib/python3.2/site-packages/MySQL_python-1.2.3-py3.2-linux-x86_64.egg/MySQLdb/cursors.py", line 330, in _query
rowcount = self._do_query(q)
File "/opt/python3/lib/python3.2/site-packages/MySQL_python-1.2.3-py3.2-linux-x86_64.egg/MySQLdb/cursors.py", line 294, in _do_query
db.query(q)
_mysql_exceptions.ProgrammingError: (1064, "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 '%s' at line 1")
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "metrites.py", line 193, in <module>
cur.execute( '''SELECT hits FROM counters WHERE url = %s''', (page,) )
File "/opt/python3/lib/python3.2/site-packages/MySQL_python-1.2.3-py3.2-linux-x86_64.egg/MySQLdb/cursors.py", line 184, in execute
self.errorhandler(self, exc, value)
File "/opt/python3/lib/python3.2/site-packages/MySQL_python-1.2.3-py3.2-linux-x86_64.egg/MySQLdb/connections.py", line 36, in defaulterrorhandler
raise errorclass(errorvalue)
_mysql_exceptions.ProgrammingError: (1064, "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 '%s' at line 1")
you can also see it at http://superhost.gr
Any ideas what might be the problem?
My webhost (hostgator.com) says that The MySQLdb module is already installed for python 3 on this server.
Can you please tell me what's the nature of this error?
Thank you.
[toc] | [next] | [standalone]
| From | MRAB <python@mrabarnett.plus.com> |
|---|---|
| Date | 2013-03-27 00:41 +0000 |
| Message-ID | <mailman.3786.1364344877.2939.python-list@python.org> |
| In reply to | #41955 |
On 26/03/2013 21:24, Νίκος Γκρ33κ wrote: > Hello today i deiced to go form python 2.6 to python 3.2.3 > > although in 2.6 my script runs in the ht enewest python i ge this error: > > > Traceback (most recent call last): > File "/opt/python3/lib/python3.2/site-packages/MySQL_python-1.2.3-py3.2-linux-x86_64.egg/MySQLdb/cursors.py", line 171, in execute > r = self._query(query) > File "/opt/python3/lib/python3.2/site-packages/MySQL_python-1.2.3-py3.2-linux-x86_64.egg/MySQLdb/cursors.py", line 330, in _query > rowcount = self._do_query(q) > File "/opt/python3/lib/python3.2/site-packages/MySQL_python-1.2.3-py3.2-linux-x86_64.egg/MySQLdb/cursors.py", line 294, in _do_query > db.query(q) > _mysql_exceptions.ProgrammingError: (1064, "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 '%s' at line 1") > > During handling of the above exception, another exception occurred: > > Traceback (most recent call last): > File "metrites.py", line 193, in <module> > cur.execute( '''SELECT hits FROM counters WHERE url = %s''', (page,) ) > File "/opt/python3/lib/python3.2/site-packages/MySQL_python-1.2.3-py3.2-linux-x86_64.egg/MySQLdb/cursors.py", line 184, in execute > self.errorhandler(self, exc, value) > File "/opt/python3/lib/python3.2/site-packages/MySQL_python-1.2.3-py3.2-linux-x86_64.egg/MySQLdb/connections.py", line 36, in defaulterrorhandler > raise errorclass(errorvalue) > _mysql_exceptions.ProgrammingError: (1064, "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 '%s' at line 1") > > > > you can also see it at http://superhost.gr > > Any ideas what might be the problem? > > My webhost (hostgator.com) says that The MySQLdb module is already installed for python 3 on this server. > > Can you please tell me what's the nature of this error? > > Thank you. > The error's in the SQL.
[toc] | [prev] | [next] | [standalone]
| From | rurpy@yahoo.com |
|---|---|
| Date | 2013-03-26 21:26 -0700 |
| Message-ID | <9c01c631-77e8-4104-ae1f-5cccfaaea10d@googlegroups.com> |
| In reply to | #41955 |
On 03/26/2013 03:24 PM, Νίκος Γκρ33κ wrote:> Hello today i deiced to go form python 2.6 to python 3.2.3 > > although in 2.6 my script runs in the ht enewest python i ge this error: > > > Traceback (most recent call last): > File "/opt/python3/lib/python3.2/site-packages/MySQL_python-1.2.3-py3.2-linux-x86_64.egg/MySQLdb/cursors.py", line 171, in execute > r = self._query(query) > File "/opt/python3/lib/python3.2/site-packages/MySQL_python-1.2.3-py3.2-linux-x86_64.egg/MySQLdb/cursors.py", line 330, in _query > rowcount = self._do_query(q) > File "/opt/python3/lib/python3.2/site-packages/MySQL_python-1.2.3-py3.2-linux-x86_64.egg/MySQLdb/cursors.py", line 294, in _do_query > db.query(q) > _mysql_exceptions.ProgrammingError: (1064, "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 '%s' at line 1") > > During handling of the above exception, another exception occurred: > > Traceback (most recent call last): > File "metrites.py", line 193, in <module> > cur.execute( '''SELECT hits FROM counters WHERE url = %s''', (page,) ) > File "/opt/python3/lib/python3.2/site-packages/MySQL_python-1.2.3-py3.2-linux-x86_64.egg/MySQLdb/cursors.py", line 184, in execute > self.errorhandler(self, exc, value) > File "/opt/python3/lib/python3.2/site-packages/MySQL_python-1.2.3-py3.2-linux-x86_64.egg/MySQLdb/connections.py", line 36, in defaulterrorhandler > raise errorclass(errorvalue) > _mysql_exceptions.ProgrammingError: (1064, "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 '%s' at line 1") > > > > you can also see it at http://superhost.gr > > Any ideas what might be the problem? > > My webhost (hostgator.com) says that The MySQLdb module is already installed for python 3 on this server. > > Can you please tell me what's the nature of this error? > > Thank you. This seems to be the problem line of code: > File "metrites.py", line 193, in <module> > cur.execute( '''SELECT hits FROM counters WHERE url = %s''', (page,) ) If 'page' is not a string as you expect, but is None or (for example) a list or something else, you might well end up with invalid SQL when MySQLdb tries to build the executable sql statement. Sorry I can't be more specific -- I haven't used MySQLdb and I'm suggesting what I'd try for any generic DBI module. If MySQLdb has a way to turn on debugging so that it prints SQL statements before execution, you might want do that. Then it may be obvious what is wrong, or if the SQL still looks ok, try copying it and pasting it in a interactive database session to see what error occurs. If not, maybe you can try adding a print statement to your code that will print the value of 'page'. This will be easier to do if you can run you code interactively. If you have to run it via a webserver than maybe you'll need wrap the print output in html commands to make it visible on the page, or to write it to a file.
[toc] | [prev] | [next] | [standalone]
| From | Νίκος Γκρ33κ <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2013-03-26 23:42 -0700 |
| Message-ID | <22f50ec2-7d20-47af-a793-5cf801b6a23e@googlegroups.com> |
| In reply to | #41977 |
Τη Τετάρτη, 27 Μαρτίου 2013 6:26:06 π.μ. UTC+2, ο χρήστης ru...@yahoo.com έγραψε: > If not, maybe you can try adding a print statement to your code that > will print the value of 'page'. This will be easier to do if you > can run you code interactively. If you have to run it via a webserver > than maybe you'll need wrap the print output in html commands to make > it visible on the page, or to write it to a file. I tried what you suggested by doign the following: print( page ) sys.exit(0) cur.execute( '''SELECT hits FROM counters WHERE url = %s''', (page,) ) and the result is printed in the webpage as 'index.html' so page seem s to be a string but the error is still persistant. Anything else i need to try?
[toc] | [prev] | [next] | [standalone]
| From | Νίκος Γκρ33κ <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2013-03-27 00:26 -0700 |
| Message-ID | <77c04488-6e61-4fb5-84b1-03335845b851@googlegroups.com> |
| In reply to | #41982 |
And also i must show you that 'page' values are calculated by:
# detect how 'index.html' is called and validate variables 'htmlpage' & 'page'
if page and os.path.isfile( '/home/nikos/www/cgi-bin/' + page ):
page = page
elif form.getvalue('show') and os.path.isfile( htmlpage ):
page = htmlpage.replace( '/home/nikos/public_html/', '' )
else:
page = 'index.html'
so in all cases theya re string.
i just dont see whats worng....
[toc] | [prev] | [next] | [standalone]
| From | Νίκος Γκρ33κ <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2013-03-27 02:58 -0700 |
| Message-ID | <ef9d27c2-3dc0-48d4-be11-2f18955807d7@googlegroups.com> |
| In reply to | #41983 |
any help here please?
[toc] | [prev] | [next] | [standalone]
| From | MRAB <python@mrabarnett.plus.com> |
|---|---|
| Date | 2013-03-27 16:48 +0000 |
| Message-ID | <mailman.3813.1364402927.2939.python-list@python.org> |
| In reply to | #41982 |
On 27/03/2013 06:42, Νίκος Γκρ33κ wrote:
> Τη Τετάρτη, 27 Μαρτίου 2013 6:26:06 π.μ. UTC+2, ο χρήστης ru...@yahoo.com έγραψε:
>
>> If not, maybe you can try adding a print statement to your code that
>> will print the value of 'page'. This will be easier to do if you
>> can run you code interactively. If you have to run it via a webserver
>> than maybe you'll need wrap the print output in html commands to make
>> it visible on the page, or to write it to a file.
>
>
> I tried what you suggested by doign the following:
>
> print( page )
> sys.exit(0)
> cur.execute( '''SELECT hits FROM counters WHERE url = %s''', (page,) )
>
>
> and the result is printed in the webpage as 'index.html'
>
> so page seem s to be a string but the error is still persistant.
> Anything else i need to try?
>
A brief look at the documentation tells me that MySQL uses '?' as the
placeholder instead of '%s':
cur.execute('''SELECT hits FROM counters WHERE url = ?''', (page, ))
[toc] | [prev] | [next] | [standalone]
| From | nagia.retsina@gmail.com |
|---|---|
| Date | 2013-03-27 11:15 -0700 |
| Message-ID | <e278ef8f-c862-4aac-bbd3-314ea9b7dd0d@googlegroups.com> |
| In reply to | #42017 |
Τη Τετάρτη, 27 Μαρτίου 2013 6:48:44 μ.μ. UTC+2, ο χρήστης MRAB έγραψε:
> On 27/03/2013 06:42, Νίκος Γκρ33κ wrote:
>
> > Τη Τετάρτη, 27 Μαρτίου 2013 6:26:06 π.μ. UTC+2, ο χρήστης ru...@yahoo.com έγραψε:
>
> >
>
> >> If not, maybe you can try adding a print statement to your code that
>
> >> will print the value of 'page'. This will be easier to do if you
>
> >> can run you code interactively. If you have to run it via a webserver
>
> >> than maybe you'll need wrap the print output in html commands to make
>
> >> it visible on the page, or to write it to a file.
>
> >
>
> >
>
> > I tried what you suggested by doign the following:
>
> >
>
> > print( page )
>
> > sys.exit(0)
>
> > cur.execute( '''SELECT hits FROM counters WHERE url = %s''', (page,) )
>
> >
>
> >
>
> > and the result is printed in the webpage as 'index.html'
>
> >
>
> > so page seem s to be a string but the error is still persistant.
>
> > Anything else i need to try?
>
> >
>
> A brief look at the documentation tells me that MySQL uses '?' as the
>
> placeholder instead of '%s':
>
>
>
> cur.execute('''SELECT hits FROM counters WHERE url = ?''', (page, ))
But as i have it used to work withour problem with pyhton 2.6
Why would it be a problem now?
[toc] | [prev] | [next] | [standalone]
| From | nagia.retsina@gmail.com |
|---|---|
| Date | 2013-03-27 11:15 -0700 |
| Message-ID | <mailman.3816.1364408106.2939.python-list@python.org> |
| In reply to | #42017 |
Τη Τετάρτη, 27 Μαρτίου 2013 6:48:44 μ.μ. UTC+2, ο χρήστης MRAB έγραψε:
> On 27/03/2013 06:42, Νίκος Γκρ33κ wrote:
>
> > Τη Τετάρτη, 27 Μαρτίου 2013 6:26:06 π.μ. UTC+2, ο χρήστης ru...@yahoo.com έγραψε:
>
> >
>
> >> If not, maybe you can try adding a print statement to your code that
>
> >> will print the value of 'page'. This will be easier to do if you
>
> >> can run you code interactively. If you have to run it via a webserver
>
> >> than maybe you'll need wrap the print output in html commands to make
>
> >> it visible on the page, or to write it to a file.
>
> >
>
> >
>
> > I tried what you suggested by doign the following:
>
> >
>
> > print( page )
>
> > sys.exit(0)
>
> > cur.execute( '''SELECT hits FROM counters WHERE url = %s''', (page,) )
>
> >
>
> >
>
> > and the result is printed in the webpage as 'index.html'
>
> >
>
> > so page seem s to be a string but the error is still persistant.
>
> > Anything else i need to try?
>
> >
>
> A brief look at the documentation tells me that MySQL uses '?' as the
>
> placeholder instead of '%s':
>
>
>
> cur.execute('''SELECT hits FROM counters WHERE url = ?''', (page, ))
But as i have it used to work withour problem with pyhton 2.6
Why would it be a problem now?
[toc] | [prev] | [next] | [standalone]
| From | Νίκος Γκρ33κ <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2013-03-27 11:27 -0700 |
| Message-ID | <3feaeaff-65c7-4a7f-ac04-b5deede798c0@googlegroups.com> |
| In reply to | #42017 |
=> 187 print ( "Query Error: ", sys.exc_info()[1].excepinfo()[2]) excepinfo is probably mis-spelled---I have no idea what you intend.l Python3 raised exceptions in an except: clause giving the double exception message that I don't think you'd have seen in python2. Maybe the purpose is to help novice python programmers who haven't learned to make try: except: clause trap a specific statement looking for specific Errors. Maybe this line which iuses to work in python 2.6 doesnt in python 3.2.3 ? do i have to switch it to soemthing else?
[toc] | [prev] | [next] | [standalone]
| From | Νίκος Γκρ33κ <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2013-03-27 11:27 -0700 |
| Message-ID | <mailman.3817.1364409562.2939.python-list@python.org> |
| In reply to | #42017 |
=> 187 print ( "Query Error: ", sys.exc_info()[1].excepinfo()[2]) excepinfo is probably mis-spelled---I have no idea what you intend.l Python3 raised exceptions in an except: clause giving the double exception message that I don't think you'd have seen in python2. Maybe the purpose is to help novice python programmers who haven't learned to make try: except: clause trap a specific statement looking for specific Errors. Maybe this line which iuses to work in python 2.6 doesnt in python 3.2.3 ? do i have to switch it to soemthing else?
[toc] | [prev] | [next] | [standalone]
| From | Νίκος Γκρ33κ <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2013-03-27 11:48 -0700 |
| Message-ID | <8ada8de4-1cb2-4fbb-ae4f-8c0d47c1cf40@googlegroups.com> |
| In reply to | #42025 |
I had encoding isseus as well! Now i tried your suggestion changing comma with '%' and now the error is more clear. [code] _mysql_exceptions.OperationalError: (1054, "Unknown column 'index.html' in 'where clause'") [/code] loook at http://superhost.gr please to see the whoel traceback
[toc] | [prev] | [next] | [standalone]
| From | Joel Goldstick <joel.goldstick@gmail.com> |
|---|---|
| Date | 2013-03-27 15:06 -0400 |
| Message-ID | <mailman.3819.1364411190.2939.python-list@python.org> |
| In reply to | #42026 |
[Multipart message — attachments visible in raw view] — view raw
On Wed, Mar 27, 2013 at 2:48 PM, Νίκος Γκρ33κ <nikos.gr33k@gmail.com> wrote: > I had encoding isseus as well! > > Now i tried your suggestion changing comma with '%' and now the error is > more clear. > > [code] > _mysql_exceptions.OperationalError: (1054, "Unknown column 'index.html' in > 'where clause'") > [/code] > > > loook at http://superhost.gr please to see the whoel traceback > -- > http://mail.python.org/mailman/listinfo/python-list > You should print the sql statement to see what is being created. Create the sql, and assign it to a variable name. Print that. Then execute the command. -- Joel Goldstick http://joelgoldstick.com
[toc] | [prev] | [next] | [standalone]
| From | Νίκος Γκρ33κ <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2013-03-27 12:13 -0700 |
| Message-ID | <3e7d6332-5ad6-4c86-8bed-c1ee63de9489@googlegroups.com> |
| In reply to | #42028 |
Τη Τετάρτη, 27 Μαρτίου 2013 9:06:27 μ.μ. UTC+2, ο χρήστης Joel Goldstick έγραψε: > You should print the sql statement to see what is being created. Create the > > >sql, and assign it to a variable name. Print that. Then execute the command. Ok Joe, i just tried the followinf as you suggested to me: try: sql = '''SELECT hits FROM counters WHERE url = %s''' print( sql ) cur.execute( sql , (page,) ) data = cur.fetchone() except MySQLdb.ProgrammingError as e: print ( "Query Error: ", dir( sys.exc_info()[1] ) ) ========= please look at http://supethost.gr now, weird errors! encoding issues perhaps?!
[toc] | [prev] | [next] | [standalone]
| From | Νίκος Γκρ33κ <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2013-03-27 12:13 -0700 |
| Message-ID | <mailman.3820.1364411632.2939.python-list@python.org> |
| In reply to | #42028 |
Τη Τετάρτη, 27 Μαρτίου 2013 9:06:27 μ.μ. UTC+2, ο χρήστης Joel Goldstick έγραψε: > You should print the sql statement to see what is being created. Create the > > >sql, and assign it to a variable name. Print that. Then execute the command. Ok Joe, i just tried the followinf as you suggested to me: try: sql = '''SELECT hits FROM counters WHERE url = %s''' print( sql ) cur.execute( sql , (page,) ) data = cur.fetchone() except MySQLdb.ProgrammingError as e: print ( "Query Error: ", dir( sys.exc_info()[1] ) ) ========= please look at http://supethost.gr now, weird errors! encoding issues perhaps?!
[toc] | [prev] | [next] | [standalone]
| From | Νίκος Γκρ33κ <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2013-03-27 12:23 -0700 |
| Message-ID | <5cc2bd2c-ec83-4881-97ce-e8e91ce72993@googlegroups.com> |
| In reply to | #42030 |
Even better: try: sql = '''SELECT hits FROM counters WHERE url = %s''' % page print( sql ) cur.execute( sql ) data = cur.fetchone() except MySQLdb.ProgrammingError as e: print ( "Query Error: ", dir( sys.exc_info()[1] ) ) ======== sql statement seems okey...
[toc] | [prev] | [next] | [standalone]
| From | Νίκος Γκρ33κ <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2013-03-27 12:23 -0700 |
| Message-ID | <mailman.3822.1364412937.2939.python-list@python.org> |
| In reply to | #42030 |
Even better: try: sql = '''SELECT hits FROM counters WHERE url = %s''' % page print( sql ) cur.execute( sql ) data = cur.fetchone() except MySQLdb.ProgrammingError as e: print ( "Query Error: ", dir( sys.exc_info()[1] ) ) ======== sql statement seems okey...
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2013-03-28 06:28 +1100 |
| Message-ID | <mailman.3821.1364412524.2939.python-list@python.org> |
| In reply to | #42026 |
On Thu, Mar 28, 2013 at 5:48 AM, Νίκος Γκρ33κ <nikos.gr33k@gmail.com> wrote:
> I had encoding isseus as well!
>
> Now i tried your suggestion changing comma with '%' and now the error is more clear.
>
> [code]
> _mysql_exceptions.OperationalError: (1054, "Unknown column 'index.html' in 'where clause'")
> [/code]
No, don't do that, that opens you up to SQL injection attacks. Read
the responses you've been given:
On Thu, Mar 28, 2013 at 3:48 AM, MRAB <python@mrabarnett.plus.com> wrote:
> A brief look at the documentation tells me that MySQL uses '?' as the
> placeholder instead of '%s':
>
> cur.execute('''SELECT hits FROM counters WHERE url = ?''', (page, ))
This is what you need to do.
ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Νίκος Γκρ33κ <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2013-03-27 12:42 -0700 |
| Message-ID | <89df4430-3b67-4e9b-bcce-4a0777df620f@googlegroups.com> |
| In reply to | #42032 |
Τη Τετάρτη, 27 Μαρτίου 2013 9:28:35 μ.μ. UTC+2, ο χρήστης Chris Angelico έγραψε:
> On Thu, Mar 28, 2013 at 3:48 AM, MRAB <python@mrabarnett.plus.com> wrote:
> > A brief look at the documentation tells me that MySQL uses '?' as the
> > placeholder instead of '%s':
> cur.execute('''SELECT hits FROM counters WHERE url = ?''', (page, ))
> This is what you need to do.
The following works in python 2.6
[code]
cur.execute( '''SELECT hits FROM counters WHERE url = %s''') , (page,)
[/code]
is there a difefrence between the above and the follwong which works in python 3.x
[code]
cur.execute( '''SELECT hits FROM counters WHERE url = %s''' , (page,) )
[/code]
I'am confused. Which one is the correct?
Also now http://superhost.gr seems to stuck in the following line which i try to open an acii file to slect a random line, please take a look.
[toc] | [prev] | [next] | [standalone]
| From | Νίκος Γκρ33κ <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2013-03-27 12:42 -0700 |
| Message-ID | <mailman.3823.1364413351.2939.python-list@python.org> |
| In reply to | #42032 |
Τη Τετάρτη, 27 Μαρτίου 2013 9:28:35 μ.μ. UTC+2, ο χρήστης Chris Angelico έγραψε:
> On Thu, Mar 28, 2013 at 3:48 AM, MRAB <python@mrabarnett.plus.com> wrote:
> > A brief look at the documentation tells me that MySQL uses '?' as the
> > placeholder instead of '%s':
> cur.execute('''SELECT hits FROM counters WHERE url = ?''', (page, ))
> This is what you need to do.
The following works in python 2.6
[code]
cur.execute( '''SELECT hits FROM counters WHERE url = %s''') , (page,)
[/code]
is there a difefrence between the above and the follwong which works in python 3.x
[code]
cur.execute( '''SELECT hits FROM counters WHERE url = %s''' , (page,) )
[/code]
I'am confused. Which one is the correct?
Also now http://superhost.gr seems to stuck in the following line which i try to open an acii file to slect a random line, please take a look.
[toc] | [prev] | [next] | [standalone]
Page 1 of 2 [1] 2 Next page →
Back to top | Article view | comp.lang.python
csiph-web