An error when i switched from python v2.6.6 => v3.2.3

Discussion in 'Python' started by Íßêïò Ãêñ33ê, Mar 7, 2013.

  1. Today i switched to Python v3.2.3 on my remote web server at HostGator.
    My cgi-script which it works at python v2.6.6 now produces theses errors:

    --> -->
    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 211, in <module>
    cur.execute( '''SELECT hits FROM counters WHERE url = %s''', (htmlpage,) )
    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")

    Even cursor.execute changes in python v3 ?

    What are these errors about?
     
    Íßêïò Ãêñ33ê, Mar 7, 2013
    #1
    1. Advertising

  2. Any ideas about the error please?

    I can assure you all the statemnt are correct ebcause they work in python v2.6.6
     
    Íßêïò Ãêñ33ê, Mar 7, 2013
    #2
    1. Advertising

  3. Ôç ÐÝìðôç, 7 Ìáñôßïõ 2013 11:06:27 ð.ì. UTC+2, ï ÷ñÞóôçò Íßêïò Ãêñ33ê Ýãñáøå:
    > Any ideas about the error please?
    >
    >
    >
    > I can assure you all the statemnt are correct ebcause they work in pythonv2.6.6


    can someone help this issue so my webiste will get back on working plz?
     
    Íßêïò Ãêñ33ê, Mar 7, 2013
    #3
  4. Íßêïò Ãêñ33ê

    Michael Ross Guest

    On Thu, 07 Mar 2013 12:27:03 +0100, Îίκος ΓκÏ33κ <>
    wrote:

    > Τη Πέμπτη, 7 ΜαÏτίου 2013 11:06:27 Ï€.μ. UTC+2, ο χÏήστης Îίκος ΓκÏ33κ
    > έγÏαψε:
    >> Any ideas about the error please?
    >>
    >>
    >>
    >> I can assure you all the statemnt are correct ebcause they work in
    >> python v2.6.6

    >
    > can someone help this issue so my webiste will get back on working plz?


    MySQLdb is python 2 only.
    "MySQL-3.23 through 5.0 and Python-2.3 through 2.7 are currently
    supported. Python-3.0 will be supported in a future release."

    Maybe try this one:
    https://pypi.python.org/pypi/mysql-connector-python/1.0.9

    Alternatively,
    forget about subprocess.check_output,
    call your metrites.py with os.system('python metrites.py some-temp-file')
    and have it write its output to some-temp-file,
    and read some-temp-file back into your template?
     
    Michael Ross, Mar 7, 2013
    #4
  5. Ôç ÐÝìðôç, 7 Ìáñôßïõ 2013 1:51:42 ì.ì. UTC+2, ï ÷ñÞóôçò Michael Ross Ýãñáøå:
    > On Thu, 07 Mar 2013 12:27:03 +0100, Íßêïò Ãêñ33ê <>
    >
    > wrote:
    >
    >
    >
    > > Ôç ÐÝìðôç, 7 Ìáñôßïõ 2013 11:06:27 ð.ì. UTC+2, ï ÷ñÞóôçò Íßêïò Ãêñ33ê

    >
    > > Ýãñáøå:

    >
    > >> Any ideas about the error please?

    >
    > >>

    >
    > >>

    >
    > >>

    >
    > >> I can assure you all the statemnt are correct ebcause they work in

    >
    > >> python v2.6.6

    >
    > >

    >
    > > can someone help this issue so my webiste will get back on working plz?

    >
    >
    >
    > MySQLdb is python 2 only.
    >
    > "MySQL-3.23 through 5.0 and Python-2.3 through 2.7 are currently
    >
    > supported. Python-3.0 will be supported in a future release."
    >
    >
    >
    > Maybe try this one:
    >
    > https://pypi.python.org/pypi/mysql-connector-python/1.0.9
    >
    >
    >
    > Alternatively,
    >
    > forget about subprocess.check_output,
    >
    > call your metrites.py with os.system('python metrites.py some-temp-file')
    >
    > and have it write its output to some-temp-file,
    >
    > and read some-temp-file back into your template?


    Yes its better for me to give upon python3 for the moment being, because all that hassle was for makeing the subprocess command run.

    Now i just followed your advice and tried:

    elif htmlpage.endswith('.py'):
    htmldata = os.system('/usr/bin/python ./metrites.py /data/files/htmltemp')

    but produced error tells me that:

    template undefined, htmldata = -1, counter = ' <center><a href="mailto:"> ...st.gr/?show=stats"><font color=cyan> 0 </td>\n\t\t '

    whay htmldata reeturn the value '-1' when os.sytem is executed?
     
    Íßêïò Ãêñ33ê, Mar 7, 2013
    #5
  6. Ôç ÐÝìðôç, 7 Ìáñôßïõ 2013 1:51:42 ì.ì. UTC+2, ï ÷ñÞóôçò Michael Ross Ýãñáøå:
    > On Thu, 07 Mar 2013 12:27:03 +0100, Íßêïò Ãêñ33ê <>
    >
    > wrote:
    >
    >
    >
    > > Ôç ÐÝìðôç, 7 Ìáñôßïõ 2013 11:06:27 ð.ì. UTC+2, ï ÷ñÞóôçò Íßêïò Ãêñ33ê

    >
    > > Ýãñáøå:

    >
    > >> Any ideas about the error please?

    >
    > >>

    >
    > >>

    >
    > >>

    >
    > >> I can assure you all the statemnt are correct ebcause they work in

    >
    > >> python v2.6.6

    >
    > >

    >
    > > can someone help this issue so my webiste will get back on working plz?

    >
    >
    >
    > MySQLdb is python 2 only.
    >
    > "MySQL-3.23 through 5.0 and Python-2.3 through 2.7 are currently
    >
    > supported. Python-3.0 will be supported in a future release."
    >
    >
    >
    > Maybe try this one:
    >
    > https://pypi.python.org/pypi/mysql-connector-python/1.0.9
    >
    >
    >
    > Alternatively,
    >
    > forget about subprocess.check_output,
    >
    > call your metrites.py with os.system('python metrites.py some-temp-file')
    >
    > and have it write its output to some-temp-file,
    >
    > and read some-temp-file back into your template?


    Yes its better for me to give upon python3 for the moment being, because all that hassle was for makeing the subprocess command run.

    Now i just followed your advice and tried:

    elif htmlpage.endswith('.py'):
    htmldata = os.system('/usr/bin/python ./metrites.py /data/files/htmltemp')

    but produced error tells me that:

    template undefined, htmldata = -1, counter = ' <center><a href="mailto:"> ...st.gr/?show=stats"><font color=cyan> 0 </td>\n\t\t '

    whay htmldata reeturn the value '-1' when os.sytem is executed?
     
    Íßêïò Ãêñ33ê, Mar 7, 2013
    #6
  7. Íßêïò Ãêñ33ê

    Michael Ross Guest

    On Thu, 07 Mar 2013 13:25:58 +0100, Îίκος ΓκÏ33κ <>
    wrote:

    > Τη Πέμπτη, 7 ΜαÏτίου 2013 1:51:42 μ.μ. UTC+2, ο χÏήστης Michael Ross
    > έγÏαψε:
    >> On Thu, 07 Mar 2013 12:27:03 +0100, Îίκος ΓκÏ33κ <>
    >>
    >> wrote:
    >>
    >>
    >>
    >> > Τη Πέμπτη, 7 ΜαÏτίου 2013 11:06:27 Ï€.μ. UTC+2, ο χÏήστης Îίκος ΓκÏ33κ

    >>
    >> > έγÏαψε:

    >>
    >> >> Any ideas about the error please?

    >>
    >> >>

    >>
    >> >>

    >>
    >> >>

    >>
    >> >> I can assure you all the statemnt are correct ebcause they work in

    >>
    >> >> python v2.6.6

    >>
    >> >

    >>
    >> > can someone help this issue so my webiste will get back on working

    >> plz?
    >>
    >>
    >>
    >> MySQLdb is python 2 only.
    >>
    >> "MySQL-3.23 through 5.0 and Python-2.3 through 2.7 are currently
    >>
    >> supported. Python-3.0 will be supported in a future release."
    >>
    >>
    >>
    >> Maybe try this one:
    >>
    >> https://pypi.python.org/pypi/mysql-connector-python/1.0.9
    >>
    >>
    >>
    >> Alternatively,
    >>
    >> forget about subprocess.check_output,
    >>
    >> call your metrites.py with os.system('python metrites.py
    >> some-temp-file')
    >>
    >> and have it write its output to some-temp-file,
    >>
    >> and read some-temp-file back into your template?

    >
    > Yes its better for me to give upon python3 for the moment being, because
    > all that hassle was for makeing the subprocess command run.
    >
    > Now i just followed your advice and tried:
    >
    > elif htmlpage.endswith('.py'):
    > htmldata = os.system('/usr/bin/python ./metrites.py
    > /data/files/htmltemp')
    >
    > but produced error tells me that:
    >
    > template undefined, htmldata = -1, counter = ' <center><a
    > href="mailto:"> ...st.gr/?show=stats"><font
    > color=cyan> 0 </td>\n\t\t '
    >
    > whay htmldata reeturn the value '-1' when os.sytem is executed?


    Because
    "On Unix, the return value is the exit status of the process encoded in
    the format specified for wait()."

    It's in the documentation for os.system.
    Which you should have read before asking here.

    You may not intend it like that,
    but if you ask any and all errors here, you effectively ask the list to
    develop the software for you.

    Seriously this is beyond the scope of volunteer help for a commercial site.
    I'm bailing out.
     
    Michael Ross, Mar 7, 2013
    #7
  8. Please tell me at least if i ahve any syntax error in this line:

    htmldata = os.system('/usr/bin/python ./metrites.py /data/files/htmltemp')

    please man its essential for my website to work otherwise 3 scripts i wrotewould not be able to produce proper html output that then i need to appenda string after them. her si what i want to do:

    if htmlpage.endswith('.html'):
    f = open( "/home/nikos/www/" + htmlpage )
    htmldata = f.read()
    elif htmlpage.endswith('.py'):
    htmldata = os.system('/usr/bin/python ./metrites.py /data/files/htmltemp')


    counter = ''' <center><a href="mailto:"> <img src="/data/images/mail.png"> </a>
    <center><table border=2 cellpadding=2 bgcolor=black>
    <td><font color=lime>Áñéèìüò Åðéóêåðôþí</td>
    <td><a href="http://superhost.gr/?show=stats"><font color=cyan> %d </td>
    ''' % data[0]


    template = htmldata + counter
    print( template )

    ======================

    Please just that i like to do it myself ut i cant, i wont ask anyhting else..
     
    Íßêïò Ãêñ33ê, Mar 7, 2013
    #8
  9. Please tell me at least if i ahve any syntax error in this line:

    htmldata = os.system('/usr/bin/python ./metrites.py /data/files/htmltemp')

    please man its essential for my website to work otherwise 3 scripts i wrotewould not be able to produce proper html output that then i need to appenda string after them. her si what i want to do:

    if htmlpage.endswith('.html'):
    f = open( "/home/nikos/www/" + htmlpage )
    htmldata = f.read()
    elif htmlpage.endswith('.py'):
    htmldata = os.system('/usr/bin/python ./metrites.py /data/files/htmltemp')


    counter = ''' <center><a href="mailto:"> <img src="/data/images/mail.png"> </a>
    <center><table border=2 cellpadding=2 bgcolor=black>
    <td><font color=lime>Áñéèìüò Åðéóêåðôþí</td>
    <td><a href="http://superhost.gr/?show=stats"><font color=cyan> %d </td>
    ''' % data[0]


    template = htmldata + counter
    print( template )

    ======================

    Please just that i like to do it myself ut i cant, i wont ask anyhting else..
     
    Íßêïò Ãêñ33ê, Mar 7, 2013
    #9
  10. On Fri, Mar 8, 2013 at 12:22 AM, Íßêïò Ãêñ33ê <> wrote:
    > Please tell me at least if i ahve any syntax error in this line:
    >
    > htmldata = os.system('/usr/bin/python ./metrites.py /data/files/htmltemp')
    >
    > please man its essential for my website to work otherwise 3 scripts i wrote would not be able to produce proper html output


    Yes, there is. The variable name at the beginning is wrong. To
    understand why, look at the documentation for os.system().

    If it's essential for your web site, why not pay someone to do the work foryou?

    You want free support AND you're not willing to put effort into your
    questions. That's a bad combination. The sloppiness of your writing,
    coupled with a clear lack of preliminary research (eg checking the
    docs), suggests that you do not value the end result; you expect
    someone else to do everything, to wave a magic wand and voila, your
    web site works. That isn't how the world works.

    Quoting from http://www.catb.org/esr/faqs/smart-questions.html
    > == Before you ask ==
    > Prepare your question. Think it through. Hasty-sounding questions get
    > hasty answers, or none at all. The more you do to demonstrate that having
    > put thought and effort into solving your problem before seeking help, the
    > more likely you are to actually get help.

    ....
    > == Write in clear, grammatical, correctly-spelled language ==
    > ... If you can't be bothered to do that, we can't be bothered to pay attention.
    > Spend the extra effort to polish your language. It doesn't have to be stiff or
    > formal - in fact, hacker culture values informal, slangy and humorous
    > language used with precision. But it has to be precise; there has to be
    > some indication that you're thinking and paying attention.
    > ... if you write like a semi-literate boob you will very likely be ignored.


    ChrisA
     
    Chris Angelico, Mar 7, 2013
    #10
  11. But iam tryign dayd for this i even tryign to chnage my 3 script to python v3.2.3 just to get subprocess up and running

    all the above fail:

    htmldata = os.system("python metrites.py '/data/files/htmltemp'")

    How can i tell system to send metritis.py's output to a temporary file called htmltemp so in the next step i can do what iam trying 3 days now to do:

    template = htmldata + counter

    os.system is very vague while i need specific help with this.
    if you provide me a link that describes my case of things i';; for sure read it.
     
    Íßêïò Ãêñ33ê, Mar 7, 2013
    #11
  12. But iam tryign dayd for this i even tryign to chnage my 3 script to python v3.2.3 just to get subprocess up and running

    all the above fail:

    htmldata = os.system("python metrites.py '/data/files/htmltemp'")

    How can i tell system to send metritis.py's output to a temporary file called htmltemp so in the next step i can do what iam trying 3 days now to do:

    template = htmldata + counter

    os.system is very vague while i need specific help with this.
    if you provide me a link that describes my case of things i';; for sure read it.
     
    Íßêïò Ãêñ33ê, Mar 7, 2013
    #12
  13. On Fri, Mar 8, 2013 at 12:56 AM, Íßêïò Ãêñ33ê <> wrote:
    > But iam tryign dayd for this i even tryign to chnage my 3 script to python v3.2.3 just to get subprocess up and running
    >
    > all the above fail:
    >
    > htmldata = os.system("python metrites.py '/data/files/htmltemp'")
    >
    > How can i tell system to send metritis.py's output to a temporary file called htmltemp so in the next step i can do what iam trying 3 days now to do:
    >
    > template = htmldata + counter
    >
    > os.system is very vague while i need specific help with this.
    > if you provide me a link that describes my case of things i';; for sure read it.


    You are panicking about specific problems. Take a deep breath, take a
    step back, and look at what's going on. If you've really been trying
    for three days to make this work, it won't cost you much more to spend
    three minutes polishing your email before you send it... or those same
    three minutes reading the docs and finding what you want.

    ChrisA
     
    Chris Angelico, Mar 7, 2013
    #13
  14. Ôç ÐÝìðôç, 7 Ìáñôßïõ 2013 4:01:13 ì.ì. UTC+2, ï ÷ñÞóôçò Chris Angelico Ýãñáøå:

    > You are panicking about specific problems. Take a deep breath, take a
    >
    > step back, and look at what's going on. If you've really been trying
    >
    > for three days to make this work, it won't cost you much more to spend
    >
    > three minutes polishing your email before you send it... or those same
    >
    > three minutes reading the docs and finding what you want.


    Iam willing to read some document that describe what iam dealing with, please provid eme a link and aill read it....

    I think its an OS issue and not statment issue.

    iam starting to hink that maybe

    python metritis.py > /data/files/htmltemp

    might work. i will try this now as we speak.lets hope for God;s sake it will work!
     
    Íßêïò Ãêñ33ê, Mar 7, 2013
    #14
  15. Ôç ÐÝìðôç, 7 Ìáñôßïõ 2013 4:01:13 ì.ì. UTC+2, ï ÷ñÞóôçò Chris Angelico Ýãñáøå:

    > You are panicking about specific problems. Take a deep breath, take a
    >
    > step back, and look at what's going on. If you've really been trying
    >
    > for three days to make this work, it won't cost you much more to spend
    >
    > three minutes polishing your email before you send it... or those same
    >
    > three minutes reading the docs and finding what you want.


    Iam willing to read some document that describe what iam dealing with, please provid eme a link and aill read it....

    I think its an OS issue and not statment issue.

    iam starting to hink that maybe

    python metritis.py > /data/files/htmltemp

    might work. i will try this now as we speak.lets hope for God;s sake it will work!
     
    Íßêïò Ãêñ33ê, Mar 7, 2013
    #15
  16. I made some progress!!! Now the htmldata's value its not -1 but 256!!!

    look the error after trying this:
    htmldata = os.system("python metrites.py > '/data/private/htmltemp'")

    ====================
    template undefined, htmldata = 256, counter = ' <center><a href="mailto:"> ...st.gr/?show=stats"><font color=cyan> 0 </td>\n\t\t '
    <type 'exceptions.TypeError'>: unsupported operand type(s) for +: 'int' and 'str'
    args = ("unsupported operand type(s) for +: 'int' and 'str'",)
    message = "unsupported operand type(s) for +: 'int' and 'str'"
     
    Íßêïò Ãêñ33ê, Mar 7, 2013
    #16
  17. I made some progress!!! Now the htmldata's value its not -1 but 256!!!

    look the error after trying this:
    htmldata = os.system("python metrites.py > '/data/private/htmltemp'")

    ====================
    template undefined, htmldata = 256, counter = ' <center><a href="mailto:"> ...st.gr/?show=stats"><font color=cyan> 0 </td>\n\t\t '
    <type 'exceptions.TypeError'>: unsupported operand type(s) for +: 'int' and 'str'
    args = ("unsupported operand type(s) for +: 'int' and 'str'",)
    message = "unsupported operand type(s) for +: 'int' and 'str'"
     
    Íßêïò Ãêñ33ê, Mar 7, 2013
    #17
  18. On Fri, Mar 8, 2013 at 1:11 AM, Íßêïò Ãêñ33ê <> wrote:
    > Ôç ÐÝìðôç, 7 Ìáñôßïõ 2013 4:01:13 ì.ì. UTC+2, ï ÷ñÞóôçò Chris Angelico Ýãñáøå:
    >
    >> You are panicking about specific problems. Take a deep breath, take a
    >>
    >> step back, and look at what's going on. If you've really been trying
    >>
    >> for three days to make this work, it won't cost you much more to spend
    >>
    >> three minutes polishing your email before you send it... or those same
    >>
    >> three minutes reading the docs and finding what you want.

    >
    > Iam willing to read some document that describe what iam dealing with, please provid eme a link and aill read it....


    http://www.google.com/

    > I think its an OS issue and not statment issue.


    I think it's a pebkac issue.

    > iam starting to hink that maybe
    >
    > python metritis.py > /data/files/htmltemp
    >
    > might work. i will try this now as we speak.lets hope for God;s sake it will work!


    Tip: Next time, try it first, THEN post. This is not IRC. You don't
    need to tell us that you're trying, and that you're panicking still
    further.

    ChrisA
     
    Chris Angelico, Mar 7, 2013
    #18
  19. On Fri, Mar 8, 2013 at 1:13 AM, Íßêïò Ãêñ33ê <> wrote:
    > I made some progress!!! Now the htmldata's value its not -1 but 256!!!
    >
    > look the error after trying this:
    > htmldata = os.system("python metrites.py > '/data/private/htmltemp'")


    Go check the docs for os.system() and understand why 'htmldata' is the
    wrong name for its return value.

    ChrisA
     
    Chris Angelico, Mar 7, 2013
    #19
  20. Docs doesn't explain that i just take looked at http://docs.python.org/2/library/os.html#os.system

    I see that the return value of os.system its an indicator to as if the command inside os.system() returned successfully.

    So i guess ill be needing somethign like this:

    htmltemp = '/home/nikos/www/data/private/htmltemp'

    if htmlpage.endswith('.html'):
    f = open( "/home/nikos/www/" + htmlpage )
    htmldata = f.read()
    elif htmlpage.endswith('.py'):
    os.system( 'python metrites.py > %s' ) % htmltemp
    f = open( htmltemp )
    htmldata = f.read()

    template = htmldata + counter
    ==============

    which i just tried and now iam receiving this:

    <type 'exceptions.TypeError'>: unsupported operand type(s) for %: 'int' and 'str'

    I'am very close to the solution now i cna feel it but please help a bit!
     
    Íßêïò Ãêñ33ê, Mar 7, 2013
    #20
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?VmxhZHk=?=
    Replies:
    1
    Views:
    432
    =?Utf-8?B?dG9tIHdpc25vd3NraQ==?=
    Oct 8, 2004
  2. Tohru Kao
    Replies:
    3
    Views:
    471
    Neil Masson
    Jul 14, 2003
  3. Tohru Kao
    Replies:
    1
    Views:
    427
    Chris
    Jul 8, 2003
  4. Dilantha Seneviratne

    How to detect if JavaScript is switched off

    Dilantha Seneviratne, Feb 16, 2004, in forum: Javascript
    Replies:
    2
    Views:
    99
    Richard Cornford
    Feb 17, 2004
  5. Law
    Replies:
    0
    Views:
    84
Loading...

Share This Page