472,784 Members | 803 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,784 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

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

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

Similar topics

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,...
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...
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...
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,...
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...
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...
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():
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 =...
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...
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.