GoogleCodeArchives / pyodbc

Automatically exported from code.google.com/p/pyodbc
MIT No Attribution
0 stars 0 forks source link

pyodbc.Row' object has no attribute 'replace' #267

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,

I am using the latest version of pyodbc on Ubuntu and have a small issue. 

The output pyodbc is giving me is always in the (222122L, ) format. I need to 
format this output to make it more readible by removing the "()" and "L". 
Apprently I cannot do this with a str.replace statement. Any ideas how to 
circumvent this?

Regards,

Ronald.

Original issue reported on code.google.com by sembcsco...@gmail.com on 25 May 2012 at 11:01

GoogleCodeExporter commented 9 years ago
I think the issue is you are using the entire *row* in your string, when you 
really just want the first column.  A row is a set of columns and is very much 
like a tuple:

Instead of:
  x = 'label: %s' % row
use:
  x = 'label: %s' % row[0]

The () are being added because the row is being asked to turn itself into a 
"repr" string and it does the same thing as a tuple.  The 'L' is added by the 
value itself for the same reason.  When you extract it, %s on the value should 
give you just 222122. 

Original comment by mkleehammer on 25 May 2012 at 3:02

GoogleCodeExporter commented 9 years ago
Tx, works like a charm!

Original comment by sembcsco...@gmail.com on 25 May 2012 at 4:49