SQLite
Last updated at 3:23 pm UTC on 29 October 2018
The Squeak wrapper for the SQLite free database server, availabe as a C library, just needs 3 simple api calls
- connect
- disconnect
- execute
Full SQL 97 (Structured Query Language) support see http://www.hwaci.com/sw/sqlite/
The SQLite3 wrapper needs FFI to connect to the C library.
SQL As Understood By SQLite
Applications of SQLite
Example:
http://www.samadhiweb.com/tags/SQLite (World Cup 2018 with Glorp, SQLite)
List of SQLite / SQLite3 wrapper implementations
2016
http://smalltalkhub.com/#!/~MilanVavra/SqueakSQLite3
Test example
| con s1 s2 s3 arrayOfDicts |
con := SQLiteConnection fileNamed: 'test.db'.
con inspect.
s1 := 'create table employee (id, name)'.
s2 := 'insert into employee values (1, ''Adam'')'.
s3 := 'insert into employee values (2, ''Eve'')'.
(Array
with: s1
with: s2
with: s3)
do: [:sql | con executeQuery: sql].
arrayOfDicts := con executeQuery: 'SELECT *FROM employee'.
arrayOfDicts inspect.
con close.
https://milanvavra.wordpress.com/2016/08/12/squeak-5-0-using-sqlite3/
You might need to send #squeakToUtf8 to the SQL statements before executing them.
For this to work in Ubuntu it needs
sudo apt-get install libsqlite3-dev
In case the api calls cannot find the library see
http://forum.world.st/SQLite-in-Squeak-Smalltalk-tp4933616p4933755.html
2014
http://smalltalkhub.com/#!/~PharoExtras/NBSQLite3
Creation date: Dec 2014
The "NBSQLite3 for Pharo" is a project to provide an API and access to the SQLite3 database from within the Pharo image.
The NB is NativeBoost which was a Pharo 4 diversion for a high performance FFI, but was x86 only and made it harder to collaborate on the VM with Squeak programmers. Pharo 5
FFI returned to the fold to use again the original-FFI & Alien, but with (IIUC) a layer called Unified FFI so NB syntax translates to original-FFI backend.
(http://forum.world.st/UFFI-on-Squeak-td4895679.html)
Note: NativeBoost is no longer used in recent Pharo versions.
2013
http://smalltalkhub.com/#!/~TorstenBergmann/SQLite
Creation date: March 2013
wrapper for the SQLite library using FFI technology
Port to Cuis Smalltalk
https://github.com/hhzl/Cuis-SQLite
2010
http://www.squeaksource.com/SQLite
Thorsten Bergmann and Andreas Raab
Registered: Jan 2010
Wrapper for the SQLite library
2005
SqueakMap
SQLite3
Fred Mannby
Nov 2005
Test code
| con s1 s2 s3 arrayOfDicts |
con := SQLiteConnection fileNamed: 'test.db'.
con inspect.
s1 := 'create table employee (id, name)'.
s2 := 'insert into employee values (1, ''Adam'')'.
s3 := 'insert into employee values (2, ''Eve'')'.
(Array
with: s1
with: s2
with: s3)
do: [:sql | con execute executeQuery: sql].
arrayOfDicts := con executeQuery: 'SELECT *FROM employee'.
arrayOfDicts inspect.
con close.
2002
There's also now a simple FFI wrapper for it at
http://beta4.com/squeak/aubergines/source/SQLite.st (no longer accessible)
SQLite (Squeak)
SqueakMap
SQLite version 2
Avi Bryant, Dec 2002
Note: it's available in sm by avi and I've tested it so I'd like to quote the code here:
| con s1 s2 s3 arrayOfDicts |
con := SQLiteConnection fileNamed: 'test.db'.
con inspect.
s1 := 'create table employee (id, name)'.
s2 := 'insert into employee values (1,''Adam'')'.
s3 := 'insert into employee values (2, ''Eve'')'.
(Array
with: s1
with: s2
with: s3)
do: [:sql | con executeQuery: sql].
arrayOfDicts := con executeQuery: 'SELECT * FROM employee'.
arrayOfDicts inspect.
con close.
Thank you, avi!
Comments