Daniel,

Thank You, that worked fine.
In case anyone else can find this useful, The final working code for converting from a 
long to a varchar is:

 import sys
 import sapdb.sql
 session=sapdb.sql.connect("DBA","PWD","DBName","ServerName")
 cursor=session.sql("select ID,Comments from table1")
 cursor.setFetchSize(1)
 update = session.prepare ("""update table1 set comments2 = ?
       where id = ?""")
 for row in cursor:
     comment=row[1].read()
     updated = update.execute ([comment, row[0]])
     session.commit() # You may not want to do this every row if you
                      # are updating a lot of them at once.

Sim
________________________________________________________________________________

I've been able to reproduce the error, but I'm still searching for the cause.

You can work around the problem through
cursor.setFetchSize (1)
The cursor will then get only one row per network request. This is slower, but it 
doesn't seem to confuse the python driver as much when LONGs are part of a row.

Daniel Dittmar

-- 
Daniel Dittmar
SAP Labs Berlin
[EMAIL PROTECTED]


> -----Original Message-----
> From: Sim Zacks [mailto:[EMAIL PROTECTED]
> Sent: Monday, July 26, 2004 4:23 PM
> To: [EMAIL PROTECTED]
> Subject: Re: python maxdb segmentation error
> 
> 
> This is a forwarded message
> From: Sim Zacks <[EMAIL PROTECTED]>
> To: "Dittmar, Daniel" <[EMAIL PROTECTED]>
> (Sorry, I noticed I hit reply before and didn't send it to the list)
> 
> I am using the python module you mentioned with Python version 2.2.1.
> It occurred again when using this method.
> Where would I find the core file? I am using Redhat 8.
> 
> Sim
> ______________________________________________________________
> __________________
> 
> > I've tried this a number of different ways, including in a 
> try except
> > block and I get a segmentation error which throws me out of python
> > completely.
> 
> Have you used the python driver from 
ftp://ftp.sap.com/pub/sapdb/bin/linux/sapdb-python-linux-i386-7.4.03.33a.tgz? The 
driver in the server installation is compiled for Python 1.5.2. It 'kind of' worked 
until Python 2.2, but 2.3 broke binary compatibility. If this doesn't fix the 
segmentation fault, then a backtrace from the core would be helpful.

This code would look better:
> import sys
> import sapdb.sql
> session=sapdb.sql.connect("DBA","PWD","DBName","ServerName")
> cursor=session.sql("select ID,Comments from table1")
  update = session.prepare ("""update table1 set comments2 = ? 
       where id = ?""")
> for row in cursor:
>     comment=row[1].read()
>     print comment
      updated = update.execute ([comment, row[0])
>     # updated=session.sql("""update table1 set comments2='%s' 
>     #  where id=%s""" % (comment,row[0]))
>     print "statement executed"
> print "all done"

That way, there are no problems if comment contains a quote character.
You should also add a session.commit () every few thousand rows and at the end of the 
loop.

Daniel Dittmar

-- 
Daniel Dittmar
SAP Labs Berlin
[EMAIL PROTECTED]


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


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

Reply via email to