Latest errors on pickled objects and blob datatypes in mysql

2007-05-07 Thread krishnakant Mane
hello,
finally the errors for my sql query have changed so I have even
changed the thread subject because I feel now that this is not doable
in mysql and this seams to be a bug, ither in python or the MySQLdb
module or perhaps both.
my table is called testobj and the blob field is called obj.
now following is my query with the cursor named CSRInsert.
CSRInsert.execute(insert into testobj (obj) values (?);,(pickled_object))
the error is,
type error, not all arguments formatted during string formatting .

can some one now figure out what could be the problem?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Latest errors on pickled objects and blob datatypes in mysql

2007-05-07 Thread Daniele Varrazzo
On 7 Mag, 19:08, krishnakant Mane [EMAIL PROTECTED] wrote:
 hello,
 finally the errors for my sql query have changed so I have even
 changed the thread subject because I feel now that this is not doable
 in mysql and this seams to be a bug, ither in python or the MySQLdb
 module or perhaps both.

And why not also a bug in MySQL? Or a neutrino hitting your CPU
changing a 0 into an 1? Doesn't the Occam razor suggest it may be your
fault? :)

 my table is called testobj and the blob field is called obj.
 now following is my query with the cursor named CSRInsert.
 CSRInsert.execute(insert into testobj (obj) values (?);,(pickled_object))
 the error is,
 type error, not all arguments formatted during string formatting .

 can some one now figure out what could be the problem?

Please, read the fine manual.

if you had read the DBAPI documentation as previously suggested, you
would know that you MUST use %s placeholder, not ? (because
MySQLdb.paramstyle == 'format'). Just replace the placeholder in your
sql string and keep passing sql and values as two distinct arguments.

The second argument of the execute() method MUST be a tuple (or a
mapping for named parameters, but let's stick to the positional ones).
(pickled_object) is not a tuple, it is just an object in
parenthesis. To represent a tuple with a single argument you must
write (pickled_object,), notice the trailing comma.

Try:

CSRInsert.execute(insert into testobj (obj) values (%s);,
(pickled_object,))

-- Daniele

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Latest errors on pickled objects and blob datatypes in mysql

2007-05-07 Thread Daniele Varrazzo
On 7 Mag, 19:08, krishnakant Mane [EMAIL PROTECTED] wrote:
 hello,
 finally the errors for my sql query have changed so I have even
 changed the thread subject because I feel now that this is not doable
 in mysql and this seams to be a bug, ither in python or the MySQLdb
 module or perhaps both.

And why not also a bug in MySQL? Or a neutrino hitting your CPU
changing a 0 into an 1? Doesn't the Occam razor suggest it may be your
fault? :)

 my table is called testobj and the blob field is called obj.
 now following is my query with the cursor named CSRInsert.
 CSRInsert.execute(insert into testobj (obj) values (?);,(pickled_object))
 the error is,
 type error, not all arguments formatted during string formatting .

 can some one now figure out what could be the problem?

Please, read the fine manual.

if you had read the DBAPI documentation as previously suggested, you
would know that you MUST use %s placeholder, not ? (because
MySQLdb.paramstyle == 'format'). Just replace the placeholder in your
sql string and keep passing sql and values as two distinct arguments.

The second argument of the execute() method MUST be a tuple (or a
mapping for named parameters, but let's stick to the positional ones).
(pickled_object) is not a tuple, it is just an object in
parenthesis. To represent a tuple with a single argument you must
write (pickled_object,), notice the trailing comma.

Try:

CSRInsert.execute(insert into testobj (obj) values (%s);,
(pickled_object,))

-- Daniele

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Latest errors on pickled objects and blob datatypes in mysql

2007-05-07 Thread Gabriel Genellina
En Mon, 07 May 2007 14:08:21 -0300, krishnakant Mane  
[EMAIL PROTECTED] escribió:

 my table is called testobj and the blob field is called obj.
 now following is my query with the cursor named CSRInsert.
 CSRInsert.execute(insert into testobj (obj) values  
 (?);,(pickled_object))
 the error is,
 type error, not all arguments formatted during string formatting .

 can some one now figure out what could be the problem?

Try exactly as advised:
CSRInsert.execute(insert into testobj (obj) values  
(?);,(pickled_object,))

-- 
Gabriel Genellina

-- 
http://mail.python.org/mailman/listinfo/python-list