dbTalk Databases Forums  

Which scripting tools to use to insert utf8 data into nvarcharcolumns?

comp.databases.ingres comp.databases.ingres


Discuss Which scripting tools to use to insert utf8 data into nvarcharcolumns? in the comp.databases.ingres forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
droesler
 
Posts: n/a

Default Which scripting tools to use to insert utf8 data into nvarcharcolumns? - 05-13-2009 , 01:46 PM






Hi,

Ingres version: II 9.2.0 (int.lnx/118)NPTL
II_CHARSET is set to ISO88591

I created a database with createdb -i and created a table with
nvarchar columns. Using scripting, how can I insert utf8 data into
this table?

Thanks

Dennis

Reply With Quote
  #2  
Old   
Grant Croker
 
Posts: n/a

Default Re: [Info-Ingres] Which scripting tools to use to insert utf8 datainto nvarchar columns? - 05-14-2009 , 06:00 AM






On/El 13/05/09 20:46, droesler wrote/escribió:
Quote:
Ingres version: II 9.2.0 (int.lnx/118)NPTL
II_CHARSET is set to ISO88591

I created a database with createdb -i and created a table with
nvarchar columns. Using scripting, how can I insert utf8 data into
this table?

Hi Dennis,

If you are looking for command line scripting then you can use PHP,
Python, or Ruby.

With PHP and the latest driver (2.1.0) all string values are assumed to
be using a UTF-8 encoding and are converted to UTF-16 when dealing with
N(VAR)CHAR columns. For this to work the following settings need to be
enabled (they are by default):

ingres.utf8
ingres.describe

"ingres.utf8" enables the automatic conversion to UTF-16 before passing
to the server. "ingres.describe" uses the "DESCRIBE INPUT" support in
Ingres to determine what the types are for parameters in a column. For
example if you have the demodb installed take a look at
http://ingres.pastebin.com/f7565ff1f. Using version 2.1.0 of the PHP
extension I get the following output:

$ php unicode.cdi.php
Get current list of airports
Barcelona - El Prat De Llobregat
Madrid - Barajas
Valladolid - Valladolid
Insert new airport:
Array
(
[ap_id] => 406
[ap_iatacode] => OVD
[ap_place] => Asturias
[ap_name] => Olviedo
[ap_ccode] => ES
)
Get new list of airports
Barcelona - El Prat De Llobregat
Madrid - Barajas
Asturias - Olviedo
Valladolid - Valladolid

As you can see from the code all the columns are n(var)char except ap_id
which is an integer.

I hope this helps.

grant

--
Grant Croker - Ingres PHP and Ruby maintainer
http://blogs.planetingres.org/grant
It was a battered yellow Citroën 2CV which had had one careful owner but
also three suicidally reckless ones.




Reply With Quote
  #3  
Old   
droesler
 
Posts: n/a

Default Re: Which scripting tools to use to insert utf8 data into nvarcharcolumns? - 05-14-2009 , 10:56 PM



On May 14, 5:00*am, Grant Croker <grant.cro... (AT) ingres (DOT) com> wrote:
Quote:
On/El 13/05/09 20:46, droesler wrote/escribió:

Ingres version: II 9.2.0 (int.lnx/118)NPTL
II_CHARSET is set to ISO88591

I created a database with createdb -i and created a table with
nvarchar columns. *Using scripting, how can I insert utf8 data into
this table?


If you are looking for command line scripting then you can use *PHP,
Python, or Ruby.

With PHP and the latest driver (2.1.0) all string values are assumed to
be using a UTF-8 encoding and are converted to UTF-16 when dealing with
N(VAR)CHAR columns. For this to work the following settings need to be
enabled (they are by default):

ingres.utf8
ingres.describe

Thanks Grant.

I had looked at the PHP examples on the community.ingres web site, but
didn't think to look at the Airline demo.

Dennis


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.