[sqlalchemy] Re: Unicode String Error on Insert

2015-03-03 Thread J.D.
My solution didn't work. I was able to get my Portuguese data to load by decoding it in ISO-8859-1, but by decoding I lose all the special characters like tildes. So I still don't understand how to get the engine to accept my data properly. J.D. On Tuesday, March 3, 2015 at 3:00:24 PM UTC-7,

[sqlalchemy] Re: Unicode String Error on Insert

2015-03-03 Thread J.D.
I actually figured this out. It had nothing to do with my SQLAlchemy create_engine configuration. The data I was trying to create an object with was in ISO-8859-1 format, so I just had to construct my Object the text decoded properly. Once I did this, the data was inserted into my sqlite3 t

[sqlalchemy] Re: unicode "everywhere"

2011-04-26 Thread Gunnlaugur Briem
Hi Chris, Use Unicode/UnicodeText wherever you have text (and are able to know its character encoding at storage time, preferably always). Text and String are really just byte sequences, and should be used if it's arbitrary bytes you want to store. If you don't have control of the DB schema, t

Re: [sqlalchemy] Re: Unicode problem with MySQL-Table with collation utf8_bin and utf8_general_ci

2010-12-14 Thread Michael Bayer
"utf-8 decode" in this case means utf8 data will be received from the database and decoded into a Python unicode object before returning the value to your application. This is a function of the String type. It only occurs if the DBAPI has been detected as not returning Python unicode objects

[sqlalchemy] Re: Unicode problem with MySQL-Table with collation utf8_bin and utf8_general_ci

2010-12-14 Thread Marko Krause
Thanks for the help so far. What I'm looking for is a possibility to get always unicode, not utf-8. My current workaround is to decode the result after every select into unicode if necessary. On 9 Dez., 16:35, Michael Bayer wrote: > specify use_unicode=0 on your MySQL engine.  SQLAlchemy will pe

[sqlalchemy] Re: Unicode Length

2009-09-05 Thread Michael Bayer
On Sep 5, 2009, at 10:40 AM, gizli wrote: > > Hi all, > > I searched the posts about this but could not find anything related. I > just had a quick question about the Unicode type and its length. > > I did a number of tests and it seems that if I specify Unicode(10) in > my column type, this doe

[sqlalchemy] Re: Unicode Results from SQL functions

2008-09-25 Thread Michael Bayer
A proposed patch which addresses the issue at the SQLAlchemy ResultProxy level is at: http://www.sqlalchemy.org/trac/ticket/1179 On Sep 25, 2008, at 3:43 PM, Shawn Church wrote: > > > On Thu, Sep 25, 2008 at 6:47 AM, Michael Bayer <[EMAIL PROTECTED] > > wrote: > Converting *all* strings to u

[sqlalchemy] Re: Unicode Results from SQL functions

2008-09-25 Thread Shawn Church
On Thu, Sep 25, 2008 at 6:47 AM, Michael Bayer <[EMAIL PROTECTED]>wrote: > Converting *all* strings to unicode would then lead to havoc as soon > as someone adds a Binary column to their schema. Another solution, > which we have support for, would be for ResultProxy to attempt to > match TypeEng

[sqlalchemy] Re: Unicode Results from SQL functions

2008-09-25 Thread Michael Bayer
On Sep 25, 2008, at 2:19 AM, Shawn Church wrote: > > > On Wed, Sep 24, 2008 at 11:04 PM, jason kirtland > <[EMAIL PROTECTED]> wrote: > > Shawn Church wrote: > > > > > > On Wed, Sep 24, 2008 at 10:45 PM, jason kirtland > <[EMAIL PROTECTED] > > > wrote: > > > > > >

[sqlalchemy] Re: Unicode Results from SQL functions

2008-09-25 Thread Michael Bayer
On Sep 25, 2008, at 2:04 AM, jason kirtland wrote: > > Shawn Church wrote: >> >> >> On Wed, Sep 24, 2008 at 10:45 PM, jason kirtland <[EMAIL PROTECTED] >> > wrote: >> >> >>Adding ?charset=utf8&use_unicode=1 to your MySQL connection URL >> is a >>much easier wa

[sqlalchemy] Re: Unicode Results from SQL functions

2008-09-24 Thread Shawn Church
On Wed, Sep 24, 2008 at 11:04 PM, jason kirtland <[EMAIL PROTECTED]>wrote: > > Shawn Church wrote: > > > > > > On Wed, Sep 24, 2008 at 10:45 PM, jason kirtland <[EMAIL PROTECTED] > > > wrote: > > > > > > Adding ?charset=utf8&use_unicode=1 to your MySQL connection URL

[sqlalchemy] Re: Unicode Results from SQL functions

2008-09-24 Thread jason kirtland
Shawn Church wrote: > > > On Wed, Sep 24, 2008 at 10:45 PM, jason kirtland <[EMAIL PROTECTED] > > wrote: > > > Adding ?charset=utf8&use_unicode=1 to your MySQL connection URL is a > much easier way to get Unicode back from all DB access. > > > Ok, that wo

[sqlalchemy] Re: Unicode Results from SQL functions

2008-09-24 Thread Shawn Church
On Wed, Sep 24, 2008 at 10:45 PM, jason kirtland <[EMAIL PROTECTED]>wrote: > Adding ?charset=utf8&use_unicode=1 to your MySQL connection URL is a > much easier way to get Unicode back from all DB access. > Ok, that works. I thought that "create_engine(uri, encoding = "latin1", convert_unicode =

[sqlalchemy] Re: Unicode Results from SQL functions

2008-09-24 Thread jason kirtland
Shawn Church wrote: > > > On Wed, Sep 24, 2008 at 7:37 PM, Michael Bayer <[EMAIL PROTECTED] > > wrote: > > we can of course add more functions to the list of "known" functions > such as ifnull() (it would be best if ifnull() is a SQL standard > function, I

[sqlalchemy] Re: Unicode Results from SQL functions

2008-09-24 Thread Shawn Church
On Wed, Sep 24, 2008 at 7:37 PM, Michael Bayer <[EMAIL PROTECTED]>wrote: > we can of course add more functions to the list of "known" functions > such as ifnull() (it would be best if ifnull() is a SQL standard > function, I'm not sure if it is). > > Not sure this will work for IFNULL since it's t

[sqlalchemy] Re: Unicode Results from SQL functions

2008-09-24 Thread Michael Bayer
On Sep 24, 2008, at 10:13 PM, Shawn Church wrote: > I am trying to construct a select query in mysql (version > 5.0.51a-3ubuntu5.3-log) using SQL functions. Once I set the > convert_unicode flag = True on my engine some function results are > returned as type str and some results are retu

[sqlalchemy] Re: Unicode not getting translated to SQL Server?

2008-08-29 Thread Mike
Hi Rick, On Aug 29, 11:02 am, "Rick Morrison" <[EMAIL PROTECTED]> wrote: > > and then I do the following where someValue happens to be a unicode > > string: > > pref.pref_value = someValue > > session.commit() > > That's not going to work with pymssql as your DBAPI. Pymssql is based on > Microsof

[sqlalchemy] Re: Unicode not getting translated to SQL Server?

2008-08-29 Thread Rick Morrison
> and then I do the following where someValue happens to be a unicode > string: > pref.pref_value = someValue > session.commit() That's not going to work with pymssql as your DBAPI. Pymssql is based on Microsoft's DBLib (circa 1991 or so), which does not support unicode and never will: it's been

[sqlalchemy] Re: Unicode not getting translated to SQL Server?

2008-08-29 Thread Mike
Hi Mr. Bayer, On Aug 29, 10:10 am, Michael Bayer <[EMAIL PROTECTED]> wrote: > On Aug 29, 2008, at 10:53 AM, Mike wrote: > > > > > If I use pymssql instead, it works. As I understand it, SA should be > > using pymssql anyway, so I don't know why this is happening. I can > > cast the unicode to a s

[sqlalchemy] Re: Unicode not getting translated to SQL Server?

2008-08-29 Thread Michael Bayer
On Aug 29, 2008, at 10:53 AM, Mike wrote: > > If I use pymssql instead, it works. As I understand it, SA should be > using pymssql anyway, so I don't know why this is happening. I can > cast the unicode to a string, so it's not a big deal. However, I > thought someone might want to know that thi

[sqlalchemy] Re: Unicode data into Binary type

2008-01-07 Thread jason kirtland
Mike Bernson wrote: > Database is mysql > > I am having a problem with unicode and binary type. > > I am using an XML parse the return Unicode strings. > > I have a table in mysql with the default character set as utf8 > > I set the charset to utf8 in the connect string to charset=utf8 > > I

[sqlalchemy] Re: unicode support for MSSQL

2007-11-25 Thread Florent Aide
On Nov 25, 2007 6:24 PM, Paul Johnston <[EMAIL PROTECTED]> wrote: > > Hi Florent, > > Just realised we'd gone quiet on this thread... > > >humm What bothers me is that I already get this comportement when > >running my query program from a Linux host (using pyodbc same version) > >but need the abo

[sqlalchemy] Re: unicode support for MSSQL

2007-11-25 Thread Rick Morrison
If memory serves, there is already an 'encoding' attribute on each Dialect instance that is normally used in conjunction with another Dialect flag 'convert_unicode'. Not sure if it dovetails with your plans, tho On 11/25/07, Paul Johnston <[EMAIL PROTECTED]> wrote: > > > Hi Florent, > > Just r

[sqlalchemy] Re: unicode support for MSSQL

2007-11-25 Thread Paul Johnston
Hi Florent, Just realised we'd gone quiet on this thread... >humm What bothers me is that I already get this comportement when >running my query program from a Linux host (using pyodbc same version) >but need the above mentioned patch on a windows host so there is >definitely a different behavio

[sqlalchemy] Re: unicode support for MSSQL

2007-11-10 Thread Florent Aide
On Nov 8, 2007 7:30 PM, Paul Johnston <[EMAIL PROTECTED]> wrote: > > Hi, > > >I have isolated the problem a little bit more: my column is defined in > >the MSSQL server as a user defined type which is based on VARCHAR. > > > > > Ok, so in this case you'd like SA to return a python unicode object w

[sqlalchemy] Re: unicode support for MSSQL

2007-11-08 Thread Rick Morrison
This is going to be messy, as the support for unicode varies among the various MSSQL DBAPIS (which is in lart part why multiple DBAPI support is needed by the MSSQL driver). ODBC looks to me to tell the best story: The newer ODBC drivers have an "autotranslate" feature that somehow retrieves the c

[sqlalchemy] Re: unicode support for MSSQL

2007-11-08 Thread Paul Johnston
Hi, >I have isolated the problem a little bit more: my column is defined in >the MSSQL server as a user defined type which is based on VARCHAR. > > Ok, so in this case you'd like SA to return a python unicode object when a VARCHAR is fetched, by decoding using the database's encoding? While I

[sqlalchemy] Re: unicode support for MSSQL

2007-11-08 Thread Florent Aide
Hi Paul and others, I attached a new patch to the ticket (#839). It corrects the comportements I have and I now receive unicode objects in all cases: either when I declared String or Unicode as the column type and whatever the type of my columns in MSSQL (varchar based or nvarchar based) I thin

[sqlalchemy] Re: unicode support for MSSQL

2007-11-08 Thread Florent Aide
On Nov 8, 2007 1:36 PM, Florent Aide <[EMAIL PROTECTED]> wrote: [...] > My patch then "works" because in fact the object that come back from > sql server is a binary string encoded using the aforementioned > 'codepage'. I had contact with Christophe de Vienne (see above) who > has access to the

[sqlalchemy] Re: unicode support for MSSQL

2007-11-08 Thread Florent Aide
On Nov 5, 2007 6:50 PM, Paul Johnston <[EMAIL PROTECTED]> wrote: [...] > Are your strings VARCHAR or NVARCHAR? > > If they're NVARCHAR, all this will just work as-is with SA and MSSQL - > are you having any specific problems? > > If they're VARCHAR, then we need to think some more. I'm still not

[sqlalchemy] Re: unicode support for MSSQL

2007-11-05 Thread Paul Johnston
Hi, >I have 10 different instances the each have their own collation names >(latin1, greek, russian...) I have a master database that references >all thos instances + their collation names. I use this master database >to create the engines to the different dbs. I would like to be able to >just pa

[sqlalchemy] Re: unicode support for MSSQL

2007-11-04 Thread Michael Bayer
On Nov 4, 2007, at 3:58 PM, Florent Aide wrote: > > But in all the cases my encoding/decoding is always on the borders of > my program and I can always count on the fact that all my "strings" > are unicode objects everywhere. > i think we're in agreement that that's the right way to do things;

[sqlalchemy] Re: unicode support for MSSQL

2007-11-04 Thread Florent Aide
On Nov 3, 2007 12:01 PM, Paul Johnston <[EMAIL PROTECTED]> wrote: > > Florent, > > >I just added ticket #839 to the trac and attached a patch that enables > >unicode conversion for MSSQL dialects. > >I tested it with pyodbc but it should work the same with the other dialects. > > > > > What's the

[sqlalchemy] Re: unicode support for MSSQL

2007-11-03 Thread Paul Johnston
Florent, >I just added ticket #839 to the trac and attached a patch that enables >unicode conversion for MSSQL dialects. >I tested it with pyodbc but it should work the same with the other dialects. > > What's the benefit of doing this? I've found that you usually want to pass python unicode o

[sqlalchemy] Re: Unicode column cannot be fetched again after a un-unicode string was inserted

2007-05-21 Thread Michael Bayer
that error is being thrown by your DBAPI (database driver), since its an OperationalError.so its something to do with your database configuration or the database-specific paramters you are sending it when you connect. On May 21, 2007, at 3:44 AM, Jiang Sanyi wrote: > The column is set

[sqlalchemy] Re: Unicode URL error

2007-03-30 Thread Michael Bayer
fix in changeset 2475 On Mar 30, 5:19 am, "Andrew Stromnov" <[EMAIL PROTECTED]> wrote: > ascii-encoded string: > > >>> url = 'mysql://login:[EMAIL PROTECTED]/adverts?charset=cp1251' > >>> engine = sqlalchemy.create_engine(url, convert_unicode=True, > >>> pool_recycle=4) > >>> metadata = sqlalche

[sqlalchemy] Re: unicode

2006-12-15 Thread Jose Soares
Thanks to Björn, I solved my problem by creating the file /usr/lib/python2.4/site-packages/sitecustomize.py like this: import sys sys.setdefaultencoding("utf-8") jo Michael Bayer ha scritto: > let me show you whats happening: > > rawdata = 'Alors vous imaginez ma surprise, au lever du

[sqlalchemy] Re: unicode

2006-12-14 Thread Michael Bayer
let me show you whats happening: rawdata = 'Alors vous imaginez ma surprise, au lever du jour, quand une dr\xc3\xb4le de petit voix m\xe2\x80\x99a r\xc3\xa9veill\xc3\xa9. Elle disait: \xc2\xab S\xe2\x80\x99il vous pla\xc3\xaet\xe2\x80\xa6 dessine-moi un mouton! \xc2\xbb\n' unicodedata = rawdata.

[sqlalchemy] Re: unicode

2006-12-14 Thread jose
Marco Mariani wrote: >Lee McFadden wrote: > > >>Going from the line number in your exception that would be because >>your columns are of type String. Change the columns to Unicode and it >>should solve your problem. >> >>foo_table = Table('foo', metadata, >>Column('id', Integer, primary_ke

[sqlalchemy] Re: unicode

2006-12-14 Thread Marco Mariani
Lee McFadden wrote: > Going from the line number in your exception that would be because > your columns are of type String. Change the columns to Unicode and it > should solve your problem. > > foo_table = Table('foo', metadata, > Column('id', Integer, primary_key=True), > Column('bar', U

[sqlalchemy] Re: unicode

2006-12-14 Thread Lee McFadden
Going from the line number in your exception that would be because your columns are of type String. Change the columns to Unicode and it should solve your problem. foo_table = Table('foo', metadata, Column('id', Integer, primary_key=True), Column('bar', Unicode(255)) ) On 12/14/06, jose

[sqlalchemy] Re: Unicode in sqlite

2006-11-06 Thread Michael Bayer
sqlite hasnt been tested with that particular configurational change (never knew it was possible, and it seems like it may not be working completely). however, SA will by default have nothing to do with unicode, if you arent using convert_unicode or any Unicode column types. "encoding" does noth

[sqlalchemy] Re: Unicode in sqlite

2006-11-06 Thread Karsten Hilbert
On Mon, Nov 06, 2006 at 02:15:20PM -0800, Paul K wrote: > My application will only use ASCII characters, ^ ... > However, with SQLalchemy, statements such as > "sqlalchemy.create_engine(self.db_uri, encoding='latin1')" don't appear to > have any effect.

[sqlalchemy] Re: unicode encoding with 0.3 utf-8

2006-10-24 Thread Michael Bayer
On Oct 24, 2006, at 7:23 AM, Alexandre CONRAD wrote: > All this seems to be working fine. I can't reproduce the initial error > when in the Pylons environement. I guess my problem comes from > Pylons/Myghty. There's another Myghty-level where strings might be > converted as well and where it can

[sqlalchemy] Re: unicode encoding with 0.3 utf-8

2006-10-24 Thread Alexandre CONRAD
> you need to get a handle on exactly what is in that column. a small > test program which retrieves it and prints it out (using no > conversion) is a good place to start. I seem to have no problem inserting and retriving data (SA alone). Having ``convert_unicode=False`` or ``convert_unico

[sqlalchemy] Re: unicode encoding with 0.3 utf-8

2006-10-23 Thread Michael Bayer
you need to get a handle on exactly what is in that column. a small test program which retrieves it and prints it out (using no conversion) is a good place to start. are you using MySQL ? it seems like MySQL can sometimes do the UTF-8 encoding on the way in automatically depending on cli