SQLite + Pharo

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
16 messages Options
Reply | Threaded
Open this post in threaded view
|

SQLite + Pharo

HilaireFernandes
Hello,

How do you guys use Sqlite with Pharo, for example to update an object
from sql table and vis versa ?

Do you use any middle man to do so?

Thanks for the tips.

Hilaire

--
Dr. Geo
http://drgeo.eu


Reply | Threaded
Open this post in threaded view
|

Re: SQLite + Pharo

Esteban A. Maringolo
Hilaire,

If you want to generate the SQL statements by hand you can use the
UDBC SQLite3 driver, or if you want o use an ORM you can use Glorp.

See: http://forum.world.st/ANN-Glorp-SQLite3-for-Pharo-5-td4899277.html#a4899303

Regards!
Esteban A. Maringolo


2016-06-30 14:53 GMT-03:00 Hilaire <[hidden email]>:

> Hello,
>
> How do you guys use Sqlite with Pharo, for example to update an object
> from sql table and vis versa ?
>
> Do you use any middle man to do so?
>
> Thanks for the tips.
>
> Hilaire
>
> --
> Dr. Geo
> http://drgeo.eu
>
>

Reply | Threaded
Open this post in threaded view
|

Re: SQLite + Pharo

HilaireFernandes
Thanks Esteban,

I guess UDBC is for Pharo 5, and for Pharo 4 it is the NB version, right?

I guess both version has the same public interface.

Hilaire


Le 30/06/2016 20:02, Esteban A. Maringolo a écrit :
> If you want to generate the SQL statements by hand you can use the
> UDBC SQLite3 driver, or if you want o use an ORM you can use Glorp.

--
Dr. Geo
http://drgeo.eu


Reply | Threaded
Open this post in threaded view
|

Re: SQLite + Pharo

HilaireFernandes
In reply to this post by Esteban A. Maringolo


Thanks Esteban,

I guess UDBC is for Pharo 5, and for Pharo 4 it is the NB version, right?

I guess both version has the same public interface.

Hilaire

Le 30/06/2016 20:02, Esteban A. Maringolo a écrit :
> Hilaire,
>
> If you want to generate the SQL statements by hand you can use the
> UDBC SQLite3 driver, or if you want o use an ORM you can use Glorp.
>
> See: http://forum.world.st/ANN-Glorp-SQLite3-for-Pharo-5-td4899277.html#a4899303
>
> Regards!
> Esteban A. Maringolo

--
Dr. Geo
http://drgeo.eu


Reply | Threaded
Open this post in threaded view
|

Re: SQLite + Pharo

Esteban A. Maringolo
In reply to this post by HilaireFernandes
2016-07-06 6:24 GMT-03:00 Hilaire <[hidden email]>:
> Thanks Esteban,
>
> I guess UDBC is for Pharo 5, and for Pharo 4 it is the NB version, right?

Right.

> I guess both version has the same public interface.

There might be a small difference in the API, because it seems more
people is using the UDBC version rather the previous one. But nothing
significant, because AFAIU the UDBC has more methods, but didn't
change the semantics.

Regards!

Esteban A. Maringolo

Reply | Threaded
Open this post in threaded view
|

Re: SQLite + Pharo

Pierce Ng-3
In reply to this post by HilaireFernandes
On Wed, Jul 06, 2016 at 11:24:51AM +0200, Hilaire wrote:
> I guess UDBC is for Pharo 5, and for Pharo 4 it is the NB version, right?

Yes.

> I guess both version has the same public interface.

Yes, but. :-) Some bits of NBSQLite3, notably the online backup API but
possibly other small stuff, isn't in UDBCSQLite3 yet.

After making UDBCSQLite3 work with Glorp on Pharo 5, I've decided/realized that
I don't have time to maintain both it and NBSQLite3. I'm leaving NBSQLite3 more
or less as is, and continue to work on UDBCSQLite3.

Pierce

Reply | Threaded
Open this post in threaded view
|

Re: SQLite + Pharo

EstebanLM

> On 09 Jul 2016, at 11:42, Pierce Ng <[hidden email]> wrote:
>
> On Wed, Jul 06, 2016 at 11:24:51AM +0200, Hilaire wrote:
>> I guess UDBC is for Pharo 5, and for Pharo 4 it is the NB version, right?
>
> Yes.
>
>> I guess both version has the same public interface.
>
> Yes, but. :-) Some bits of NBSQLite3, notably the online backup API but
> possibly other small stuff, isn't in UDBCSQLite3 yet.
>
> After making UDBCSQLite3 work with Glorp on Pharo 5, I've decided/realized that
> I don't have time to maintain both it and NBSQLite3. I'm leaving NBSQLite3 more
> or less as is, and continue to work on UDBCSQLite3.

+1
I think this is the way to go :)

>
> Pierce
>


Reply | Threaded
Open this post in threaded view
|

Re: SQLite + Pharo

mbratch
Is UDBCSQLite3 available somewhere? I've tried Google and it turns up
nothing but maybe two threads discussing it.


On 7/9/2016 6:33 AM, Esteban Lorenzano wrote:

>> On 09 Jul 2016, at 11:42, Pierce Ng <[hidden email]> wrote:
>>
>> On Wed, Jul 06, 2016 at 11:24:51AM +0200, Hilaire wrote:
>>> I guess UDBC is for Pharo 5, and for Pharo 4 it is the NB version, right?
>> Yes.
>>
>>> I guess both version has the same public interface.
>> Yes, but. :-) Some bits of NBSQLite3, notably the online backup API but
>> possibly other small stuff, isn't in UDBCSQLite3 yet.
>>
>> After making UDBCSQLite3 work with Glorp on Pharo 5, I've decided/realized that
>> I don't have time to maintain both it and NBSQLite3. I'm leaving NBSQLite3 more
>> or less as is, and continue to work on UDBCSQLite3.
> +1
> I think this is the way to go :)
>
>> Pierce
>>
>


Reply | Threaded
Open this post in threaded view
|

Re: SQLite + Pharo

stepharo
In reply to this post by EstebanLM


Le 9/7/16 à 12:33, Esteban Lorenzano a écrit :

>> On 09 Jul 2016, at 11:42, Pierce Ng <[hidden email]> wrote:
>>
>> On Wed, Jul 06, 2016 at 11:24:51AM +0200, Hilaire wrote:
>>> I guess UDBC is for Pharo 5, and for Pharo 4 it is the NB version, right?
>> Yes.
>>
>>> I guess both version has the same public interface.
>> Yes, but. :-) Some bits of NBSQLite3, notably the online backup API but
>> possibly other small stuff, isn't in UDBCSQLite3 yet.
>>
>> After making UDBCSQLite3 work with Glorp on Pharo 5, I've decided/realized that
>> I don't have time to maintain both it and NBSQLite3. I'm leaving NBSQLite3 more
>> or less as is, and continue to work on UDBCSQLite3.
> +1
> I think this is the way to go :)
+ 1 :)

>
>> Pierce
>>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: SQLite + Pharo

HilaireFernandes
In reply to this post by Pierce Ng-3
Le 09/07/2016 11:42, Pierce Ng a écrit :

> After making UDBCSQLite3 work with Glorp on Pharo 5, I've decided/realized that
> I don't have time to maintain both it and NBSQLite3. I'm leaving NBSQLite3 more
> or less as is, and continue to work on UDBCSQLite3.

It is fine and your contribution is nice!
I am in the process of learning how to use sqlite3 (itself and with
Pharo) and it is coincidence my working image is Pharo4, but later it
will move to newer Pharo5.

One question on the top of my head, is how you deal with concurrent
access to sqlite tables from seaside sessionS.
Is the solution as naive as a waiting loop for the database to become
accessible ?

Thanks

Hilaire

--
Dr. Geo
http://drgeo.eu


Reply | Threaded
Open this post in threaded view
|

Re: SQLite + Pharo

vonbecmann
In reply to this post by mbratch
Mark,
  im using this 

Metacello new
 smalltalkhubUser: 'TorstenBergmann' project: 'UDBC';
 configuration: 'UDBC';
 version: #bleedingEdge;
 load.

on pharo 5


On Sat, Jul 9, 2016 at 7:41 AM, Mark Bratcher <[hidden email]> wrote:
Is UDBCSQLite3 available somewhere? I've tried Google and it turns up nothing but maybe two threads discussing it.



On 7/9/2016 6:33 AM, Esteban Lorenzano wrote:
On 09 Jul 2016, at 11:42, Pierce Ng <[hidden email]> wrote:

On Wed, Jul 06, 2016 at 11:24:51AM +0200, Hilaire wrote:
I guess UDBC is for Pharo 5, and for Pharo 4 it is the NB version, right?
Yes.

I guess both version has the same public interface.
Yes, but. :-) Some bits of NBSQLite3, notably the online backup API but
possibly other small stuff, isn't in UDBCSQLite3 yet.

After making UDBCSQLite3 work with Glorp on Pharo 5, I've decided/realized that
I don't have time to maintain both it and NBSQLite3. I'm leaving NBSQLite3 more
or less as is, and continue to work on UDBCSQLite3.
+1
I think this is the way to go :)

Pierce







--
Bernardo E.C.

Sent from a cheap desktop computer in South America.
Reply | Threaded
Open this post in threaded view
|

Re: SQLite + Pharo

Esteban A. Maringolo
In reply to this post by HilaireFernandes

The SQLite shared library is thread safe by default, so you shouldn't worry about that.

El jul. 9, 2016 7:50 AM, "Hilaire" <[hidden email]> escribió:
Le 09/07/2016 11:42, Pierce Ng a écrit :

> After making UDBCSQLite3 work with Glorp on Pharo 5, I've decided/realized that
> I don't have time to maintain both it and NBSQLite3. I'm leaving NBSQLite3 more
> or less as is, and continue to work on UDBCSQLite3.

It is fine and your contribution is nice!
I am in the process of learning how to use sqlite3 (itself and with
Pharo) and it is coincidence my working image is Pharo4, but later it
will move to newer Pharo5.

One question on the top of my head, is how you deal with concurrent
access to sqlite tables from seaside sessionS.
Is the solution as naive as a waiting loop for the database to become
accessible ?

Thanks

Hilaire

--
Dr. Geo
http://drgeo.eu


Reply | Threaded
Open this post in threaded view
|

Re: SQLite + Pharo

HilaireFernandes
Hi Esteban,

What is exactly thread safe from the Pharo perspective?
Is Sqlite library handling the conflict of access, and put on wait an
access not possible at a given moment, or does it signal it is busy?
In the later case handling a wait may be necessary.

I'm planing to use sql to manage users, groups, etc, then Fuel for
business model where concurrent access does not exist.

About Sql use with Smalltalk, I was looking for examples of best
practice, but I did not find much.

Thanks

Hilaire

Le 10/07/2016 16:24, Esteban A. Maringolo a écrit :
> The SQLite shared library is thread safe by default, so you shouldn't
> worry about that.

--
Dr. Geo
http://drgeo.eu


Reply | Threaded
Open this post in threaded view
|

Re: SQLite + Pharo

HilaireFernandes
Hi,

So what is it exactly regarding busy state of Sqlite?
The documentation is very short, to not say inexistant, on that specific
important matter.

I am just learning statement, it is nice the Pharo Sqlite pacakge comes
with it to avoid sql malware injection.

Thanks

Hilaire


Le 10/07/2016 17:04, Hilaire a écrit :

> Hi Esteban,
>
> What is exactly thread safe from the Pharo perspective?
> Is Sqlite library handling the conflict of access, and put on wait an
> access not possible at a given moment, or does it signal it is busy?
> In the later case handling a wait may be necessary.
>
> I'm planing to use sql to manage users, groups, etc, then Fuel for
> business model where concurrent access does not exist.
>
> About Sql use with Smalltalk, I was looking for examples of best
> practice, but I did not find much.
>
> Thanks
>
> Hilaire
>
> Le 10/07/2016 16:24, Esteban A. Maringolo a écrit :
>> > The SQLite shared library is thread safe by default, so you shouldn't
>> > worry about that.

--
Dr. Geo
http://drgeo.eu


Reply | Threaded
Open this post in threaded view
|

Re: SQLite + Pharo

alistairgrant


On 12/07/2016 10:19 AM, "Hilaire" <[hidden email]> wrote:
>
> Hi,
>
> So what is it exactly regarding busy state of Sqlite?
> The documentation is very short, to not say inexistant, on that specific
> important matter.

I also haven't read anything official, but my experience is that if the db is locked sqlite waits a while. If the db unlocks, the transaction succeeds, if not, an error is returned.

Cheers,
Alistair

Reply | Threaded
Open this post in threaded view
|

Re: SQLite + Pharo

Esteban A. Maringolo
I have no experience with SQLite other than for testing it on Glorp
and using it in Android (that provides a locking mechanism to queue
requests), but according to the documentation it depends on how the
SQLite connection is opened, if it is opened in "Serialized" mode [1],
then it is safe to have a multi threaded application operating on a
single db file. Also, according to the docs the access is controlled
by means of file locking [2], so if everything is finalized/closed
properly you shouldn't have this issue.

Regards!

[1] https://www.sqlite.org/threadsafe.html
[2] https://www.sqlite.org/howtocorrupt.html
Esteban A. Maringolo


2016-07-12 6:20 GMT-03:00 Alistair Grant <[hidden email]>:

>
> On 12/07/2016 10:19 AM, "Hilaire" <[hidden email]> wrote:
>>
>> Hi,
>>
>> So what is it exactly regarding busy state of Sqlite?
>> The documentation is very short, to not say inexistant, on that specific
>> important matter.
>
> I also haven't read anything official, but my experience is that if the db
> is locked sqlite waits a while. If the db unlocks, the transaction succeeds,
> if not, an error is returned.
>
> Cheers,
> Alistair