Quantcast

SQLite in Squeak Smalltalk

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

SQLite in Squeak Smalltalk

Edwin Ancaer
Hello,

I would like to use SQLite in a Squeak project. I currently use Squeak 5.1 on the raspberry Pi.

 I found the 'List of SQLite / SQLite3 wrapper implementations' on the squeak wiki. The most recent wrapper is NBSQLite3 (2014), but that seems to be specific for Pharo.  I installed the one before that, SQLite (2013), reported as 'might be outdated'.

After installation,all tests failed. It must have something to do with the  FFI settings, because when I add the location of the SQLite.so in the module: parameter  off the cdel's of the external functions, there are just 2 errors remaining. 

Before I start looking into this any further, I would like to ask if this SQLite wrapper is the correct one to use?

Kind regards


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: SQLite in Squeak Smalltalk

Ben Coman
On Thu, Feb 9, 2017 at 8:01 PM, Edwin Ancaer <[hidden email]> wrote:
> Hello,
>
> I would like to use SQLite in a Squeak project. I currently use Squeak 5.1
> on the raspberry Pi.
>
>  I found the 'List of SQLite / SQLite3 wrapper implementations' on the
> squeak wiki. The most recent wrapper is NBSQLite3 (2014), but that seems to
> be specific for Pharo.

Yes. That would be Pharo only.  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 folks.  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)

>  I installed the one before that, SQLite (2013),
> reported as 'might be outdated'.
>
> After installation,all tests failed. It must have something to do with the
> FFI settings, because when I add the location of the SQLite.so in the
> module: parameter  off the cdel's of the external functions, there are just
> 2 errors remaining.
>
> Before I start looking into this any further, I would like to ask if this
> SQLite wrapper is the correct one to use?

From a distance, this one from 2016 has potential...
http://smalltalkhub.com/#!/~MilanVavra/SqueakSQLite3

cheers -ben

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: SQLite in Squeak Smalltalk

vaidasd
Hello Edwin,
My setup was different, 64 bit Ubuntu, but I am pretty sure suggestions from here will work for you, see comments also:
https://milanvavra.wordpress.com/2016/08/12/squeak-5-0-using-sqlite3/
regards,
Vaidotas

On Thu, Feb 9, 2017 at 3:08 PM, Ben Coman <[hidden email]> wrote:
On Thu, Feb 9, 2017 at 8:01 PM, Edwin Ancaer <[hidden email]> wrote:
> Hello,
>
> I would like to use SQLite in a Squeak project. I currently use Squeak 5.1
> on the raspberry Pi.




Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: SQLite in Squeak Smalltalk

Edwin Ancaer
In reply to this post by Ben Coman
Ben, Vaidotas, 

thanks for helping me out. The version at http://smalltalkhub.com/#!/~MilanVavra/SqueakSQLite3
is working, but only after I added the module: parameter in the api... method definitions in the class, eg.

<cdecl: long 'sqlite3_open' (char* SqliteReference*) module: 'libsqlite3.so.0'>

I found the module: parameter http://wiki.squeak.org/squeak/2426
Is this new for FFI in Squeak 5, or is there still something wrong with my FFI settings?

Kind regards, 

2017-02-09 13:08 GMT+00:00 Ben Coman <[hidden email]>:
On Thu, Feb 9, 2017 at 8:01 PM, Edwin Ancaer <[hidden email]> wrote:
> Hello,
>
> I would like to use SQLite in a Squeak project. I currently use Squeak 5.1
> on the raspberry Pi.
>
>  I found the 'List of SQLite / SQLite3 wrapper implementations' on the
> squeak wiki. The most recent wrapper is NBSQLite3 (2014), but that seems to
> be specific for Pharo.

Yes. That would be Pharo only.  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 folks.  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)

>  I installed the one before that, SQLite (2013),
> reported as 'might be outdated'.
>
> After installation,all tests failed. It must have something to do with the
> FFI settings, because when I add the location of the SQLite.so in the
> module: parameter  off the cdel's of the external functions, there are just
> 2 errors remaining.
>
> Before I start looking into this any further, I would like to ask if this
> SQLite wrapper is the correct one to use?

From a distance, this one from 2016 has potential...
http://smalltalkhub.com/#!/~MilanVavra/SqueakSQLite3

cheers -ben




Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: SQLite in Squeak Smalltalk

Bert Freudenberg
On Fri, Feb 10, 2017 at 5:05 AM, Edwin Ancaer <[hidden email]> wrote:
Ben, Vaidotas, 

thanks for helping me out. The version at http://smalltalkhub.com/#!/~MilanVavra/SqueakSQLite3
is working, but only after I added the module: parameter in the api... method definitions in the class, eg.

<cdecl: long 'sqlite3_open' (char* SqliteReference*) module: 'libsqlite3.so.0'>

I found the module: parameter http://wiki.squeak.org/squeak/2426
Is this new for FFI in Squeak 5, or is there still something wrong with my FFI settings?

I guess it would work if you symlink libsqlite3.so.0 to libsqlite3.so, either manually or by installing the sqlite3-dev package. Alternatively, change SqliteLibrary class>>moduleName to return 'libsqlite3.so.0'.

All FFI functions in an ExternalLibrary subclass share the class's moduleName, instead of having to declare it in every method. SqliteLibrary is an ExternalLibrary subclass, and it declares its moduleName as 'sqlite3'. That should work, since the VM adds a 'lib' prefix and a '.so' suffix (see sqUnixExternalPrims.c).

The way other FFI libraries handle this is by making the moduleName method answer different names for each platform. E.g. Nicolas' Smallapack library does this:

moduleName
"Return the name of the module for this library
this should depend on host machine"
moduleName ifNil:
[moduleName := self isUnix
ifTrue: [self unixModuleName]
ifFalse: [self isMacOS
ifTrue: [self macOsxModuleName]
ifFalse: [self win32ModuleName]].
self new forceLoading].
^moduleName

unixModuleName
<preference: 'The name of the FORTRAN Lapack library on Unix'
category: 'Smallapack'
description: 'Check for existing liblapack-dev package.'
type: #String>
^unixModuleName ifNil: [ 'liblapack.so' ]

... which allows you to change the library name as a preference. (it also mentions the liblapack-dev package, which provides the .so symlink)

- Bert -


Loading...