----- Original Message ----- From: "Daniel Dittmar" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Wednesday, February 14, 2007 1:13 AM
Subject: Re: maxdb python inserting lobs


Luca Calderano wrote:
Can someone explain me how to insert data into lob fields using the maxdb python interface?

Use prepared statements (http://dev.mysql.com/doc/maxdb/en/20/512a7c5647e64a863683cc6333617b/frameset.htm)

As the parameter passed to the execute method, you can use either
- a string: prepared.execute (['lob value'])
- the read method of a file object: prepared.execute ([open ('somefile.txt', 'r').read]) It should be the read method (open().read), not the result of the read call, which would place a large string in memory first.

Daniel

I'm going to explain my Real problem

I'm not actually able to insert data il a lob column ...

so I'm going to explain what I want to do.

The table which I want the lob data to be inserted is defined this way:

CREATE TABLE "GestionePratiche"."PrevisioniNote"
(
"IDPrevisioniNote" Fixed (10,0) NOT NULL DEFAULT SERIAL (1),
"NumeroPratica" Integer NOT NULL,
"Note" Long UNICODE NOT NULL,
"DataRif" Date NOT NULL,
"DataReg" Date NOT NULL,
"DataAnnullamento" Date NOT NULL DEFAULT '1900-01-01',
"DataRegistrazione" Timestamp NOT NULL DEFAULT TIMESTAMP,
"Operatore" Varchar (32) ASCII NOT NULL DEFAULT USER,
PRIMARY KEY ("IDPrevisioniNote")
)

... and this is the mod_python function I use to insert values in it

def Note_Registra(req):
   req.session = _sessionManager(req)
   dati = req.form.getfirst('noteData')
   dataReg = time.strftime('%Y%m%d',time.localtime())
   dataRif = dati.split('~')[0].replace('-','')
   note = dati.split('~')[1]

insert = req.session['cnn'].prepare("""INSERT INTO "GestionePratiche"."PrevisioniNote" VALUES ( DEFAULT , %s, ?, '%s', '%s', DEFAULT , DEFAULT , DEFAULT )
""" % (req.session['CL'], dataRif, dataReg))
   insert.execute([str(note)])
   return "Dati inviati al server"

when I shoot this function I don't receive any error, but the table doesn't contain the new values

please help Me
--
MaxDB Discussion Mailing List
For list archives: http://lists.mysql.com/maxdb
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to