[cx-oracle-users] RE: [DB-SIG] cx_Oracle and Unicode ???
Brought to you by:
atuining
|
From: Marcos P. <ma...@bu...> - 2005-05-06 07:52:10
|
I am not aware of any algorythm that can extract this information.
I guess this shoud work...
codPythonOracle=3D{
'WE8ISO8859P1':'iso-8859-1',
'WE8ISO8859P15':'iso-8859-15',
'WE8MSWIN1252':'cp1252',
'AL32UTF8':'utf8',
}
El jue, 05-05-2005 a las 13:08 -0400, Mark Bennett escribi=C3=B3:
> Hello Marcos,
>=20
> Thanks for the info. I had see reference to the NLS stuff before, but =
didn't know much about it.
>=20
> I ran your basic query:
> select value=20
> from v$nls_parameters=20
> where parameter =3D 'NLS_CHARACTERSET'
>=20
> But what I got back was:
>=20
> VALUE
> -----
> AL32UTF8
>=20
> That doesn't map into your codPythonOracle dictionary.
>=20
> In deference to Guido's comment, since I think this is likely to apply =
to any of the Oracle database drivers (NLS is an Oracle thing), hoping it=
's OK to keep chatting here.
>=20
> Mark
>=20
> -----Original Message-----
> From: Marcos S=C3=A1nchez Provencio [mailto:ma...@bu...]
> Sent: Thursday, May 05, 2005 12:29 PM
> To: gu...@py...
> Cc: cx-...@li...; mar...@gm...
> Subject: Re: [DB-SIG] cx_Oracle and Unicode ???
>=20
>=20
> This is what I do (not tested, I had to trim out a lot of uninteresting
> code):
>=20
> import cx_Oracle as dbapi
>=20
> codPythonOracle=3D{
> 'WE8ISO8859P1':'iso-8859-1',
> 'WE8ISO8859P15':'iso-8859-15',
> 'WE8MSWIN1252':'cp1252',
> }
>=20
> con=3Ddbapi.connect(usuario, clave, dsn)
> sqlCodOracle=3D'''select value=20
> from v$nls_parameters=20
> where parameter =3D 'NLS_CHARACTERSET' '''
> cur=3Dcon.cursor()
> cur.execute(sqlCodOracle)
> codOracle=3Dcur.fetchone()[0]
> codificacion=3DcodPythonOracle[codOracle]
>=20
> #Then, encode the sql accordingly
> if isinstance(sql, unicode):
> sql=3Dsql.encode(self.codificacion)
> =20
> I hope it helps. This should be handled by cx_Oracle, I suppose...
>=20
>=20
> El jue, 05-05-2005 a las 08:43 -0700, Guido van Rossum escribi=C3=B3:
> > Maybe this is more an issue for the cx-oracle mailing list? (Google f=
or it.)
> >=20
> > I'd be interested in hearing the answer too.
> >=20
> > On 5/5/05, Mark Bennett <mbe...@id...> wrote:
> > > =20
> > > Good morning Folks,=20
> > > =20
> > > I've looked around on Google for this a few times and really haven'=
t come up
> > > with anything definitive.=20
> > > =20
> > > I'm trying to update values in Oracle with the .execute() method fr=
om
> > > cx_Oracle.=20
> > > =20
> > > If I create a Python unicode string object and try to pass it in, P=
ython
> > > complains that .execute() expects a None or string.=20
> > > =20
> > > If I convert the unicode string to a regular "byte" string beforeha=
nd with
> > > .encode() and utf-8, Python accepts it but when we pull the data ba=
ck from
> > > Oracle we get garbage characters.=20
> > > =20
> > > Some details:=20
> > > =20
> > > Python 2.4 with a recent version of cx_Oracle (don't have the exact=
version
> > > here) Running on Solaris.=20
> > > =20
> > > And from our DBA:
> > > =20
> > > Oracle 9 on Solaris. The database was told to support Unicode.=20
> > > =20
> > > The character fields are currently VARCHAR2; he believes he's seen
> > > conflicting evidence online about whether or not that is supposed t=
o work.=20
> > > We've also talked about using NVARCHAR2 and NCLOB.=20
> > > =20
> > > We have not set any environment variables on Solaris.=20
> > > =20
> > > Thanks in advance,=20
> > > Mark=20
> > > =20
> > > _______________________________________________
> > > DB-SIG maillist - DB...@py...
> > > http://mail.python.org/mailman/listinfo/db-sig
> > >=20
> > >=20
> > >=20
> >=20
> >=20
>=20
>=20
|