glorp, UDBC and Sqlite3

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

glorp, UDBC and Sqlite3

Renaud
Hi All.

I'm trying to be more familiar with Glorp, using sqlite. For this, I have started to run through the example given in 
https://github.com/SquareBracketAssociates/PharoInProgress/blob/master/Glorp/Glorp.pillar. I'm aware this is a work in progress, but the issue is not related to the code given in this document.

I have created the various classes mentionned at the beginning, and I'm stuck where I need to create the table in the database.

Here is my code.

"GAGlorpDriver beGlorpDefaultDriver."

| login accessor session|

login := Login new
    database: UDBCSQLite3Platform new;
    host: SmalltalkImage current imagePath asFileReference parent fullName,
      FileSystem disk delimiter asString;
    port: '';
    username: '';
    password: '';
    databaseName: 'glorpbook.db'.

PharoDatabaseAccessor DefaultDriver: GlorpSQLite3Driver.

accessor := PharoDatabaseAccessor forLogin: login.
accessor login.

"(accessor isLoggedIn)"
"(accessor basicExecuteSQLString: 'SELECT 3+4') explore. "

session := GlorpBookDescriptorSystem sessionForLogin: login.
session login.

"session createTables."

It fails in 'session login.' with "Message not understood: UDBCSQLite3Connection >> queryEncoding"
Everything else before is working: login, accessor and session are all created and working.

I have GlorpSession login which call GlorpSession loginIfError: system platform characterEncoding: accessor encoding., which in turn call PharoDatabaseAccessor >> encoding
^self connection queryEncoding

There is no method in Pharo implementing queryEncoding, so I'm stuck here.

Should I use something else than UDBC ? Are there any alternative of Sqlite ?

Thanks in advance for your help
Renaud



--
You received this message because you are subscribed to the Google Groups "glorp-group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/glorp-group.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: glorp, UDBC and Sqlite3

Alistair Grant
Hi Renaud,

See http://forum.world.st/Glorp-SQLite3-issue-td4899792.html#a4899999

Cheers,
Alistair


On Wednesday, 28 September 2016 06:23:06 UTC+2, Renaud wrote:
Hi All.

I'm trying to be more familiar with Glorp, using sqlite. For this, I have started to run through the example given in 
<a href="https://github.com/SquareBracketAssociates/PharoInProgress/blob/master/Glorp/Glorp.pillar" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2FSquareBracketAssociates%2FPharoInProgress%2Fblob%2Fmaster%2FGlorp%2FGlorp.pillar\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF0XFStOLnkQVBkDESN-sEqnBI8rA&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2FSquareBracketAssociates%2FPharoInProgress%2Fblob%2Fmaster%2FGlorp%2FGlorp.pillar\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF0XFStOLnkQVBkDESN-sEqnBI8rA&#39;;return true;">https://github.com/SquareBracketAssociates/PharoInProgress/blob/master/Glorp/Glorp.pillar. I'm aware this is a work in progress, but the issue is not related to the code given in this document.

I have created the various classes mentionned at the beginning, and I'm stuck where I need to create the table in the database.

Here is my code.

"GAGlorpDriver beGlorpDefaultDriver."

| login accessor session|

login := Login new
    database: UDBCSQLite3Platform new;
    host: SmalltalkImage current imagePath asFileReference parent fullName,
      FileSystem disk delimiter asString;
    port: '';
    username: '';
    password: '';
    databaseName: 'glorpbook.db'.

PharoDatabaseAccessor DefaultDriver: GlorpSQLite3Driver.

accessor := PharoDatabaseAccessor forLogin: login.
accessor login.

"(accessor isLoggedIn)"
"(accessor basicExecuteSQLString: 'SELECT 3+4') explore. "

session := GlorpBookDescriptorSystem sessionForLogin: login.
session login.

"session createTables."

It fails in 'session login.' with "Message not understood: UDBCSQLite3Connection >> queryEncoding"
Everything else before is working: login, accessor and session are all created and working.

I have GlorpSession login which call GlorpSession loginIfError: system platform characterEncoding: accessor encoding., which in turn call PharoDatabaseAccessor >> encoding
^self connection queryEncoding

There is no method in Pharo implementing queryEncoding, so I'm stuck here.

Should I use something else than UDBC ? Are there any alternative of Sqlite ?

Thanks in advance for your help
Renaud



--
You received this message because you are subscribed to the Google Groups "glorp-group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/glorp-group.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: glorp, UDBC and Sqlite3

Alistair Grant
In reply to this post by Renaud
I didn't mean to link to my reply where I added #queryEncoding, I'm actually using code based on Pierce's sample:

    | workingDir dbName login accessor session | 
    workingDir := SmalltalkImage current imagePath asFileReference parent fullName, 
        FileSystem disk delimiter asString. 
    dbName := 'sodbxtestu.db'. 
    login := Login new 
        database: UDBCSQLite3Platform new; 
        host: workingDir; 
        port: ''; 
        username: ''; 
        password: ''; 
        databaseName: dbName; 
        yourself. 
    PharoDatabaseAccessor DefaultDriver: GlorpSQLite3Driver. 
    accessor := PharoDatabaseAccessor forLogin: login. 
    accessor login. 
    [   session := GlorpSession new. 
        session system: (GlorpDemoDescriptorSystem forPlatform: login database). 
        session accessor: accessor. 
        session beginTransaction. 
        session inUnitOfWorkDo: [   
            | table row | 
            table := session system tableNamed: 'GR_ADDRESS'. 
            row := DatabaseRow newForTable: table. 
            row at: (table fieldNamed: 'ID') put: 1. 
            row at: (table fieldNamed: 'STREET') put: 'Alpha'. 
            row at: (table fieldNamed: 'HOUSE_NUM') put: '300'.
            session writeRow: row ]. 
        session commitTransaction. 
    ] ensure: [ accessor logout ] 

It's worthwhile reading Pierce's entire reply.

Cheers,
Alistair


On Wednesday, 28 September 2016 06:23:06 UTC+2, Renaud wrote:
Hi All.

I'm trying to be more familiar with Glorp, using sqlite. For this, I have started to run through the example given in 
<a href="https://github.com/SquareBracketAssociates/PharoInProgress/blob/master/Glorp/Glorp.pillar" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2FSquareBracketAssociates%2FPharoInProgress%2Fblob%2Fmaster%2FGlorp%2FGlorp.pillar\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF0XFStOLnkQVBkDESN-sEqnBI8rA&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2FSquareBracketAssociates%2FPharoInProgress%2Fblob%2Fmaster%2FGlorp%2FGlorp.pillar\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF0XFStOLnkQVBkDESN-sEqnBI8rA&#39;;return true;">https://github.com/SquareBracketAssociates/PharoInProgress/blob/master/Glorp/Glorp.pillar. I'm aware this is a work in progress, but the issue is not related to the code given in this document.

I have created the various classes mentionned at the beginning, and I'm stuck where I need to create the table in the database.

Here is my code.

"GAGlorpDriver beGlorpDefaultDriver."

| login accessor session|

login := Login new
    database: UDBCSQLite3Platform new;
    host: SmalltalkImage current imagePath asFileReference parent fullName,
      FileSystem disk delimiter asString;
    port: '';
    username: '';
    password: '';
    databaseName: 'glorpbook.db'.

PharoDatabaseAccessor DefaultDriver: GlorpSQLite3Driver.

accessor := PharoDatabaseAccessor forLogin: login.
accessor login.

"(accessor isLoggedIn)"
"(accessor basicExecuteSQLString: 'SELECT 3+4') explore. "

session := GlorpBookDescriptorSystem sessionForLogin: login.
session login.

"session createTables."

It fails in 'session login.' with "Message not understood: UDBCSQLite3Connection >> queryEncoding"
Everything else before is working: login, accessor and session are all created and working.

I have GlorpSession login which call GlorpSession loginIfError: system platform characterEncoding: accessor encoding., which in turn call PharoDatabaseAccessor >> encoding
^self connection queryEncoding

There is no method in Pharo implementing queryEncoding, so I'm stuck here.

Should I use something else than UDBC ? Are there any alternative of Sqlite ?

Thanks in advance for your help
Renaud



--
You received this message because you are subscribed to the Google Groups "glorp-group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/glorp-group.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: glorp, UDBC and Sqlite3

Renaud
Thanks Alistair for your quick answers.

I can see the trick here.
In the DescriptorSystem class >> sessionForLogin: method, it use (DatabaseAccessor forLogin: aGlorpLogin), instead of (PharoDatabaseAccessor forLogin: login).
I can see the difference when I inspect the session.

When created with
sessionForLogin, its databaseDriver is nil.
When created step by step as described in your post (and Pierce code sample), databaseDriver is set correctly to GlorpSqlite3Driver.

I guess sessionForLogin: shouldn't be used directly when dealing with Sqlite database.

Thanks again for your help.
Renaud


Le mercredi 28 septembre 2016 04:20:04 UTC-4, [hidden email] a écrit :
I didn't mean to link to my reply where I added #queryEncoding, I'm actually using code based on Pierce's sample:

    | workingDir dbName login accessor session | 
    workingDir := SmalltalkImage current imagePath asFileReference parent fullName, 
        FileSystem disk delimiter asString. 
    dbName := 'sodbxtestu.db'. 
    login := Login new 
        database: UDBCSQLite3Platform new; 
        host: workingDir; 
        port: ''; 
        username: ''; 
        password: ''; 
        databaseName: dbName; 
        yourself. 
    PharoDatabaseAccessor DefaultDriver: GlorpSQLite3Driver. 
    accessor := PharoDatabaseAccessor forLogin: login. 
    accessor login. 
    [   session := GlorpSession new. 
        session system: (GlorpDemoDescriptorSystem forPlatform: login database). 
        session accessor: accessor. 
        session beginTransaction. 
        session inUnitOfWorkDo: [   
            | table row | 
            table := session system tableNamed: 'GR_ADDRESS'. 
            row := DatabaseRow newForTable: table. 
            row at: (table fieldNamed: 'ID') put: 1. 
            row at: (table fieldNamed: 'STREET') put: 'Alpha'. 
            row at: (table fieldNamed: 'HOUSE_NUM') put: '300'.
            session writeRow: row ]. 
        session commitTransaction. 
    ] ensure: [ accessor logout ] 

It's worthwhile reading Pierce's entire reply.

Cheers,
Alistair


On Wednesday, 28 September 2016 06:23:06 UTC+2, Renaud wrote:
Hi All.

I'm trying to be more familiar with Glorp, using sqlite. For this, I have started to run through the example given in 
<a href="https://github.com/SquareBracketAssociates/PharoInProgress/blob/master/Glorp/Glorp.pillar" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2FSquareBracketAssociates%2FPharoInProgress%2Fblob%2Fmaster%2FGlorp%2FGlorp.pillar\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF0XFStOLnkQVBkDESN-sEqnBI8rA&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2FSquareBracketAssociates%2FPharoInProgress%2Fblob%2Fmaster%2FGlorp%2FGlorp.pillar\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF0XFStOLnkQVBkDESN-sEqnBI8rA&#39;;return true;">https://github.com/SquareBracketAssociates/PharoInProgress/blob/master/Glorp/Glorp.pillar. I'm aware this is a work in progress, but the issue is not related to the code given in this document.

I have created the various classes mentionned at the beginning, and I'm stuck where I need to create the table in the database.

Here is my code.

"GAGlorpDriver beGlorpDefaultDriver."

| login accessor session|

login := Login new
    database: UDBCSQLite3Platform new;
    host: SmalltalkImage current imagePath asFileReference parent fullName,
      FileSystem disk delimiter asString;
    port: '';
    username: '';
    password: '';
    databaseName: 'glorpbook.db'.

PharoDatabaseAccessor DefaultDriver: GlorpSQLite3Driver.

accessor := PharoDatabaseAccessor forLogin: login.
accessor login.

"(accessor isLoggedIn)"
"(accessor basicExecuteSQLString: 'SELECT 3+4') explore. "

session := GlorpBookDescriptorSystem sessionForLogin: login.
session login.

"session createTables."

It fails in 'session login.' with "Message not understood: UDBCSQLite3Connection >> queryEncoding"
Everything else before is working: login, accessor and session are all created and working.

I have GlorpSession login which call GlorpSession loginIfError: system platform characterEncoding: accessor encoding., which in turn call PharoDatabaseAccessor >> encoding
^self connection queryEncoding

There is no method in Pharo implementing queryEncoding, so I'm stuck here.

Should I use something else than UDBC ? Are there any alternative of Sqlite ?

Thanks in advance for your help
Renaud



--
You received this message because you are subscribed to the Google Groups "glorp-group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/glorp-group.
For more options, visit https://groups.google.com/d/optout.