« Previous  |  Next »

Pharo SQLite I18N Enhancements

2 March 2019

I've enhanced the Pharo SQLite library to be even more multilingual. It has always supported data elements that are Pharo WideString instances, these being converted to/from UTF8 transparently by the library. Now the library also handles multilingual table names, column names and default column values; in other words, multilingual SQL statements.

To install in Pharo 7, load GlorpSQLite from the Catalog Browser.


| db |
db := UDBCSQLite3Connection openOn: '/tmp/ml.db'.
[   "Chinese table name, column names, and default column value."   
    db basicExecute:  'create table 表一 (键一 integer primary key, 列二 text default ''中文'');'.
    "Insert a row, taking default column value for the 2nd column."
    db basicExecute: 'insert into 表一 (键一) values (NULL)'.
    "Insert another row, specifying a value in Chinese for the 2nd column."
    db execute: 'insert into 表一 values (NULL, ?)' 
        with: (Array with: '值二').
    (db execute: 'select * from 表一') rows inspect.
] ensure: [ db close ]

Inspector shows that it isn't quite I18N, although Transcript is:

Pharo SQLite I18N

From the SQLite shell:

% sqlite3 /tmp/ml.db 
SQLite version 3.27.2 2019-02-25 16:06:06
Enter ".help" for usage hints.
sqlite> .header on
sqlite> .schema 
CREATE TABLE 表一 (键一 integer primary key, 列二 text default '中文');
sqlite> select * from 表一;

Testing and feedback welcome, especially on which other parts of the library needing internationalization.

Blog comments powered by Disqus