tanrj / pyodbc

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

How to always return unicode instead of str in rows #36

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I always want unicode strings in the result set rows.

The attached patch adds the keyword argument unicode_strings to
pyodbc.connect(). If it's true, then strings are returned as unicode objects.

Original issue reported on code.google.com by patrik.simons@neotide.fi on 18 Feb 2009 at 6:00

Attachments:

GoogleCodeExporter commented 8 years ago
This is a fantastic patch -- consistent even with the pyodbc quirks (differing 
names
of Booleans).

I've applied and tested it (adding a new test to the sqlserver tests, need to 
add to
other db unittests).

The only question I have is should the keyword be unicode_strings or just 
unicode?

Are there other unicode-related flags that may come up (e.g. force unicode 
queries,
cursor.description fields, etc.)?  If so, would unicode_strings be descriptive 
enough
to differentiate from these future flags?  Would something like unicode_results 
be
better?  I'm leaning towards this.

Original comment by mkleehammer on 18 Mar 2009 at 4:43

GoogleCodeExporter commented 8 years ago
I changed the keyword to unicode_results; I hope you don't mind.  

Thanks again for the extraordinary attention to detail in your patch.

Patch applied to 2.1.5-beta6 0f921e360dad63f6745bceb693cd36b3102caa12, so it 
will be
in the official 2.1.5

Original comment by mkleehammer on 18 Mar 2009 at 4:53

GoogleCodeExporter commented 8 years ago
I don't mind. I only need the functionality, the exact implementation is not 
important.

Original comment by patrik.simons@neotide.fi on 18 Mar 2009 at 7:40

GoogleCodeExporter commented 8 years ago

Original comment by mkleehammer on 21 Nov 2010 at 4:44