473,405 Members | 2,294 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Invalid Literal from MySQLdb Query

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
Jul 18 '05 #1
0 1452

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Chris Stromberger | last post by:
When issuing updates in mysql (in the console window), mysql will tell you if any rows matched and how many rows were updated (see below). I know how to get number of rows udpated using MySQLdb,...
1
by: Sheila King | last post by:
I have searched for an answer to this question on the comp.lang.python archives at Google Groups, and also looked through the (sparse) MySQLdb documentation, and cannot confirm for a FACT what I...
1
by: JZ | last post by:
I cannot execute insert data into TEXT field if that data is bigger than 64KB. :( >>> cursor.execute("INSERT INTO table (field) VALUES(%s) WHERE id=1", myValue) Traceback (most recent call...
2
by: Tim Williams | last post by:
I'm trying to write a simple python program to access a MySQL database. I'm having a problem with using MySQLdb to get the results of a SQL command in a cursor. Sometimes the cursor.execute works,...
21
by: John Fabiani | last post by:
Hi, I'm a newbie and I'm attempting to learn howto create a select statement. When I use >>> string1='18 Tadlock Place' >>> cursor.execute("SELECT * FROM mytest where address = %s",string1) All...
2
by: m0226065 | last post by:
Ok so I have a mySQL server and mySQLdb as an interface (do I us this term correct here?) to this server from python now I have a game: I want to read a file into the db I want other data to...
5
by: Nicolay A. Vasiliev | last post by:
Hello there! I got some trouble trying to insert data into the database with MySQLdb module. I have such code: from MySQLdb import * def loc_connect_db():
1
by: David | last post by:
Hi, I cannot get the following (MS Access) SQL statement working in my asp page, please can anyone help me ? Thanks :-) ------------------------------------------------ <% strQuery =...
2
by: Nikhil | last post by:
I am using the MySQLdb python module. I have a table named 'testing' with few columns, under the 'test' database, what is hosted on a remote mysql server. I want to run the following query to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.