[DB-SIG] mysql string length?

Lukasz Szybalski szybalski at gmail.com
Fri Apr 14 19:00:09 CEST 2006

I am trying to implement an database program but I am having these
problems for which i don't seem to find an answer.

1. One of my columns in table_x is :
body text not null

when i use python to create sql :
INSERT INTO table_x( body)VALUES( '%s')" %  (body)

this body is a string that varies in size. I keep getting an error if
the size of body is longer then 255, and if its smaller everything
goes smooth. Is this syntax correct? should '%s' be something else?

2. I get an error when i close() a connection and then reopen it in
the same program. Is there a way around it. Here is more details on
what i do.

main :
do function 1
do function 2

function 1:
open connection to db
get cursor
close cursor
close connection

function 2:
open connection to db
get cursor
close cursor
close connection
go to sleep for 6 hours
go to function 1

I need to disconnect and then connect to db. Is there a reason i get
(0, '') as an exception error? I read in docs that you can't
disconnect and then connect, is that true? And if so is there a way
around it? The easiest way to do it would be to keep the connection
alive but that would mean the database will be filled with inactive
connection, that might disconnect.

Thank You

Lukasz Szybalski

More information about the DB-SIG mailing list