Cannot run a single MySQLdb execute....

  • Thread starter Íßêïò Ãêñ33ê
  • Start date
Í

Íßêïò Ãêñ33ê

I'am about to go nuts with python 3.2.3

Do you see somehtign wrong with the following statement?

cur.execute( '''SELECT hits FROM counters WHERE url = ?''', (page,) )
data = cur.fetchone()

because as you can see by visiting my webpage at http://superhost.gr it produces an error and i dont have aclue why.

Please help. i'am using MySQLdb
 
C

Chris Angelico

I'am about to go nuts with python 3.2.3

Do you see somehtign wrong with the following statement?

cur.execute( '''SELECT hits FROM counters WHERE url = ?''', (page,) )
data = cur.fetchone()

because as you can see by visiting my webpage at http://superhost.gr it produces an error and i dont have aclue why.

Please help. i'am using MySQLdb

Is this the docs for the module you're using?
http://mysql-python.sourceforge.net/MySQLdb.html
"""
paramstyle
String constant stating the type of parameter marker formatting
expected by the interface. Set to 'format' = ANSI C printf format
codes, e.g. '...WHERE name=%s'. If a mapping object is used for
conn.execute(), then the interface actually uses 'pyformat' = Python
extended format codes, e.g. '...WHERE name=%(name)s'. However, the API
does not presently allow the specification of more than one style in
paramstyle.

Note that any literal percent signs in the query string passed to
execute() must be escaped, i.e. %%.

Parameter placeholders can only be used to insert column values. They
can not be used for other parts of SQL, such as table names,
statements, etc.
"""

What paramstyle are you using?

ChrisA
 
Í

Íßêïò Ãêñ33ê

Ôç ÐÝìðôç, 28 Ìáñôßïõ 2013 6:00:17 ð.ì. UTC+2, ï ÷ñÞóôçò Chris Angelico Ýãñáøå:
What paramstyle are you using?

Yes it is Chris, but i'am not sure what exactly are you asking me.
Please if you cna pout it even simper for me, thank you.
 
Í

Íßêïò Ãêñ33ê

Ôç ÐÝìðôç, 28 Ìáñôßïõ 2013 6:00:17 ð.ì. UTC+2, ï ÷ñÞóôçò Chris Angelico Ýãñáøå:
What paramstyle are you using?

Yes it is Chris, but i'am not sure what exactly are you asking me.
Please if you cna pout it even simper for me, thank you.
 
Í

Íßêïò Ãêñ33ê

If you mean if iam using '?' or this '%s' the latter used to work flawlessly with python 2.6 but it does not in pythin 3.2.3

both this command fail in python 3.x

cur.execute( '''SELECT hits FROM counters WHERE url = ?''', (page,) )

cur.execute( '''SELECT hits FROM counters WHERE url = %s''', (page,) )

i dont have a clue why....
 
Í

Íßêïò Ãêñ33ê

If you mean if iam using '?' or this '%s' the latter used to work flawlessly with python 2.6 but it does not in pythin 3.2.3

both this command fail in python 3.x

cur.execute( '''SELECT hits FROM counters WHERE url = ?''', (page,) )

cur.execute( '''SELECT hits FROM counters WHERE url = %s''', (page,) )

i dont have a clue why....
 
C

Chris Angelico

Ôç ÐÝìðôç, 28 Ìáñôßïõ 2013 6:00:17 ð.ì.UTC+2, ï ÷ñÞóôçò Chris Angelico Ýãñáøå:


Yes it is Chris, but i'am not sure what exactly are you asking me.
Please if you cna pout it even simper for me, thank you.

As it says in that document, paramstyle is a top-level module
attribute. Try printing it out. See what it says. Then match your code
to it.

ChrisA
 
C

Chris Angelico

If you mean if iam using '?' or this '%s' the latter used to work flawlessly with python 2.6 but it does not in pythin 3.2.3

Print out the value of that attribute.

ChrisA
 
Í

Íßêïò Ãêñ33ê

Ôç ÐÝìðôç, 28 Ìáñôßïõ 2013 6:08:28 ð.ì. UTC+2, ï ÷ñÞóôçò Chris Angelico Ýãñáøå:
As it says in that document, paramstyle is a top-level module
attribute. Try printing it out. See what it says. Then match your code

sql = '''SELECT hits FROM counters WHERE url = %s''' % page
print( sql )
cur.execute( sql )

Now the error says:

_mysql_exceptions.OperationalError: (1054, "Unknown column 'index.html' in 'where clause'") as you cna see at my webpage
 
Í

Íßêïò Ãêñ33ê

Ôç ÐÝìðôç, 28 Ìáñôßïõ 2013 6:08:28 ð.ì. UTC+2, ï ÷ñÞóôçò Chris Angelico Ýãñáøå:
As it says in that document, paramstyle is a top-level module
attribute. Try printing it out. See what it says. Then match your code

sql = '''SELECT hits FROM counters WHERE url = %s''' % page
print( sql )
cur.execute( sql )

Now the error says:

_mysql_exceptions.OperationalError: (1054, "Unknown column 'index.html' in 'where clause'") as you cna see at my webpage
 
C

Chris Angelico

Ôç ÐÝìðôç, 28 Ìáñôßïõ 2013 6:08:28 ð.ì.UTC+2, ï ÷ñÞóôçò Chris Angelico Ýãñáøå:


sql = '''SELECT hits FROM counters WHERE url = %s''' % page
print( sql )
cur.execute( sql )

Now the error says:

_mysql_exceptions.OperationalError: (1054, "Unknown column 'index.html' in 'where clause'") as you cna see at my webpage

http://www.facepalm.de/

Do you understand SQL injection attacks and the concept of
parameterized queries?

ChrisA
 
Í

Íßêïò Ãêñ33ê

Ôç ÐÝìðôç, 28 Ìáñôßïõ 2013 6:26:48 ð.ì. UTC+2, ï ÷ñÞóôçò Chris Angelico Ýãñáøå:
http://www.facepalm.de/



Do you understand SQL injection attacks and the concept of

parameterized queries?



ChrisA

Yes i know i'am not supposed to use "%s" and i dotn want to but you asked me to print the sql statemnt before executing it.

please its 6:30am here in greece and didnt had any sleep yet.
please tell me whats wrong....
 
Í

Íßêïò Ãêñ33ê

Ôç ÐÝìðôç, 28 Ìáñôßïõ 2013 6:26:48 ð.ì. UTC+2, ï ÷ñÞóôçò Chris Angelico Ýãñáøå:
http://www.facepalm.de/



Do you understand SQL injection attacks and the concept of

parameterized queries?



ChrisA

Yes i know i'am not supposed to use "%s" and i dotn want to but you asked me to print the sql statemnt before executing it.

please its 6:30am here in greece and didnt had any sleep yet.
please tell me whats wrong....
 
C

Chris Angelico

Ôç ÐÝìðôç, 28 Ìáñôßïõ 2013 6:26:48 ð.ì.UTC+2, ï ÷ñÞóôçò Chris Angelico Ýãñáøå:

Yes i know i'am not supposed to use "%s" and i dotn want to but you askedme to print the sql statemnt before executing it.

please its 6:30am here in greece and didnt had any sleep yet.
please tell me whats wrong....

No. I said to print out the paramstyle attribute. If it's that late
and you haven't slept, get some sleep, then reread this thread. You
may be able to respond more intelligently.

ChrisA
 
Í

Íßêïò Ãêñ33ê

Ôç ÐÝìðôç, 28 Ìáñôßïõ 2013 6:35:14 ð.ì. UTC+2, ï ÷ñÞóôçò Chris Angelico Ýãñáøå:
No. I said to print out the paramstyle attribute. If it's that late

and you haven't slept, get some sleep, then reread this thread. You

may be able to respond more intelligently.

What is a paramstyle attribute?

Tell me what exactly it is in simple words and i;ll print it for you.

I can't get any sleep because ia'am too tense with this issue.
 
Í

Íßêïò Ãêñ33ê

Ôç ÐÝìðôç, 28 Ìáñôßïõ 2013 6:35:14 ð.ì. UTC+2, ï ÷ñÞóôçò Chris Angelico Ýãñáøå:
No. I said to print out the paramstyle attribute. If it's that late

and you haven't slept, get some sleep, then reread this thread. You

may be able to respond more intelligently.

What is a paramstyle attribute?

Tell me what exactly it is in simple words and i;ll print it for you.

I can't get any sleep because ia'am too tense with this issue.
 
Í

Íßêïò Ãêñ33ê

Can someone else esxcept Chris help me please?

I'm strugling with this and cannot see whats wrong.
 
Í

Íßêïò Ãêñ33ê

Can someone else esxcept Chris help me please?

I'm strugling with this and cannot see whats wrong.
 
D

David M Chess

Íßêïò Ãêñ33ê said:
Yes it is Chris, but i'am not sure what exactly are you asking me.
Please if you cna pout it even simper for me, thank you.

For instance:

'format'

FWIW and HTH,
DC
 
Í

Íßêïò Ãêñ33ê

Ôç ÐÝìðôç, 28 Ìáñôßïõ 2013 4:51:16 ì.ì. UTC+2, ï ÷ñÞóôçò David M Chess Ýãñáøå:
Íßêïò Ãêñ33ê <[email protected]>
:







For instance:




'format'


(e-mail address removed) [~]# /usr/bin/python3
Python 3.2.3 (default, May 23 2012, 18:47:48)
[GCC 4.4.6 20110731 (Red Hat 4.4.6-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,189
Members
46,734
Latest member
manin

Latest Threads

Top