Invalid Literal from MySQLdb Query

Discussion in 'Python' started by Wesley Kincaid, Sep 28, 2004.

  1. I'm attempting to run a simple query through MySQLdb's
    cursor.execute(). However, when the request includes a timestamp
    field, I'm getting "ValueError: invalid literal for int(): 9-."

    Could someone please explain what I'm doing wrong?


    The table is served off of MySQL 4.0.20 and contains the following
    fields:

    doc_id ... int(64)
    doc_author ... varchar(255)
    doc_created ... timestamp(14)
    doc_updated ... timestamp(14)
    doc_data ... longtext


    Here's an example of the code I'm attempting:

    Python 2.3.4 (#1, Sep 24 2004, 12:07:36)
    [GCC 2.95.4 20011002 (Debian prerelease)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import MySQLdb
    >>> db = MySQLdb.connect(host="HOSTNAME", user="USER",

    passwd="PASSWD", db="DB")
    >>> cursor = db.cursor()
    >>> cursor.execute("select * from documents")

    Traceback (most recent call last):
    File "<stdin>", line 1, in ?
    File "/home/oneofmanyme/local/lib/python2.3/site-packages/MySQLdb/cursors.py",
    line 95, in execute return self._execute(query, args)
    File "/home/oneofmanyme/local/lib/python2.3/site-packages/MySQLdb/cursors.py",
    line 114, in _execute self.errorhandler(self, exc, value)
    File "/home/oneofmanyme/local/lib/python2.3/site-packages/MySQLdb/connections.py",
    line 33, in defaulterrorhandler raise errorclass, errorvalue
    ValueError: invalid literal for int(): 9-


    If I don't include timestamps (such as doc_created) in the query,
    things work just fine:

    >>> cursor.execute("select doc_id, doc_author from documents")

    1L
    >>> print cursor.fetchone()

    (1L, 'oneofmanyme')


    Much thanks in advance,
    Wesley
     
    Wesley Kincaid, Sep 28, 2004
    #1
    1. Advertisements

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. Ton K.
    Replies:
    3
    Views:
    459
    Ton K.
    Jul 7, 2003
  2. Tim Williams
    Replies:
    2
    Views:
    867
    Tim Williams
    May 28, 2004
  3. =?ISO-8859-2?Q?Martin_MOKREJ=A9?=

    ValueError: invalid literal for int(): 1.0000000000e+00

    =?ISO-8859-2?Q?Martin_MOKREJ=A9?=, Feb 14, 2005, in forum: Python
    Replies:
    1
    Views:
    510
    Grant Edwards
    Feb 14, 2005
  4. Terry Reedy
    Replies:
    0
    Views:
    3,021
    Terry Reedy
    Feb 15, 2005
  5. Replies:
    8
    Views:
    485
    Fredrik Lundh
    Dec 12, 2006
  6. davidj411
    Replies:
    11
    Views:
    1,598
    Kam-Hung Soh
    May 29, 2008
  7. Alexander Eisenhuth
    Replies:
    4
    Views:
    1,558
    Alexander Eisenhuth
    Jul 14, 2010
  8. Anonieko Ramos

    What's wrong with rpc-literal? Why use doc-literal?

    Anonieko Ramos, Sep 27, 2004, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    632
    Anonieko Ramos
    Sep 27, 2004
Loading...