Is there a good example of an app using SqueakDBX to output data?

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

Is there a good example of an app using SqueakDBX to output data?

Frank Church

I am looking for a SqueakDBX demo that shows how to display the output of records from the database, like outputting them in a tabular format.

Does anyone know of an example somewhere?

--
Frank Church

=======================
http://devblog.brahmancreations.com
Reply | Threaded
Open this post in threaded view
|

Re: Is there a good example of an app using SqueakDBX to output data?

Mariano Martinez Peck


On Sat, Dec 4, 2010 at 2:52 AM, Frank Church <[hidden email]> wrote:

I am looking for a SqueakDBX demo that shows how to display the output of records from the database, like outputting them in a tabular format.
 
Does anyone know of an example somewhere?


HI Frank. All the applications I know are using SqueakDBX but trought GlorpDBX (an ORM). But anyway, I am not sure I undertand your problem. I recommend you to take a look to all the tests in the class DBXQueryTest.

For example, you can do this:

testIterateResultSet
    | conn result select aRow |
    conn := self doConnectAndOpen.
    select := 'SELECT * FROM student'.
    result := conn execute: select.
    [ aRow := result nextRow.
"Do something with aRow"
 ] doWhileTrue: [ aRow notNil ].
    self assert: aRow isNil.
    result releaseResult.
    conn disconnect

And to DBXRow, you can ask values (accessing by index or by name), descriptions, converting or not so String, etc...

For example, check the class DBXTranscript >> showResultSet: resultSet
showResultSet: resultSet
    | stream |
    stream := String new writeStream.
    resultSet columnDescriptions
        do: [:each | stream nextPutAll: each name]
        separatedBy: [stream nextPutAll: ' | '].
    Transcript show: stream contents;
         cr.
    resultSet
        rowsDo: [:row |
            stream := String new writeStream.
            row values
                do: [:each | stream nextPutAll: each asDbxString]
                separatedBy: [stream nextPutAll: ' | '].
            Transcript show: stream contents;
                 cr]


What I mean is that since you have reified DBXRow, DBXResultSet, etc...then you can do whatever you want with that.

Cheers

Mariano


 
--
Frank Church

=======================
http://devblog.brahmancreations.com

Reply | Threaded
Open this post in threaded view
|

Re: Is there a good example of an app using SqueakDBX to output data?

Jimmie Houchin-5
In reply to this post by Frank Church
On 12/3/2010 7:52 PM, Frank Church wrote:
>
> I am looking for a SqueakDBX demo that shows how to display the output
> of records from the database, like outputting them in a tabular format.
>
> Does anyone know of an example somewhere?
>

Hello,

I apologize, I didn't even see this message until I saw Mariano's reply.

I use SqueakDBX directly without Glorp connecting to a PostgreSQL
database with about 50 million rows currently. I am storing minutes of
financial data. Since my data is by its nature very tabular I saw no
need for using an ORM.

My use is very simple but maybe it will help.

I currently only use SqueakDBX for retrieving this data. The data is
inserted via a different program.

Here is the method I use to get my data and insert it into a Matrix.

loadOHLC
     "Loads the Open High Low Close (bid/ask) and hlavg, hlcavg  columns
from the database.
      Creates a OneWeekData (Matrix) object for the data."

     | con rows |
     con := self otogConnection.
     rows := (con execute: 'select startdate, bidopen, bidhigh, bidlow,
bidclose, askopen, askhigh, asklow, askclose from ', self instrument, '
where (', self week asDbxString, ' < startdate) AND (startdate < ', self
weekEnd asDbxString , ')') rows.
     ohlc := OneWeekData rows: (rows size) columns: 10.
     1 to: rows size do: [:row || newRow |
         newRow := ((rows at: row) values).  newRow := newRow copyWith:
(((newRow at: 3) + (newRow at: 4) + (newRow at: 5)) / 3).
         ohlc atRow: row put: newRow ].

Maybe this real world example will help. As I said my usage is simple.
SqueakDBX has worked very well for me.

I simply wrote the sql statement I wanted executed with my columns
ordered as I wanted for the rows retrieved. If I remember correctly each
rows values are when passed the "values" message return an Array which
is what I pass to my Matrix.

If we aren't providing  the answers desired. Please provide more
information to direct us. Mariano has been very helpful for any of my
questions.

Jimmie

Reply | Threaded
Open this post in threaded view
|

Re: Is there a good example of an app using SqueakDBX to output data?

Mariano Martinez Peck


On Sun, Dec 5, 2010 at 4:41 PM, Jimmie Houchin <[hidden email]> wrote:
On 12/3/2010 7:52 PM, Frank Church wrote:

I am looking for a SqueakDBX demo that shows how to display the output of records from the database, like outputting them in a tabular format.

Does anyone know of an example somewhere?


Hello,

I apologize, I didn't even see this message until I saw Mariano's reply.

I use SqueakDBX directly without Glorp connecting to a PostgreSQL database with about 50 million rows currently.

wait.....did I read correctly ????  50 millioons rows ?????   hey....you are our biggest client ;) heheheh
 
I am storing minutes of financial data. Since my data is by its nature very tabular I saw no need for using an ORM.

That completly makes sense.
 

My use is very simple but maybe it will help.

I currently only use SqueakDBX for retrieving this data. The data is inserted via a different program.

Here is the method I use to get my data and insert it into a Matrix.

loadOHLC
   "Loads the Open High Low Close (bid/ask) and hlavg, hlcavg  columns from the database.
    Creates a OneWeekData (Matrix) object for the data."

   | con rows |
   con := self otogConnection.
   rows := (con execute: 'select startdate, bidopen, bidhigh, bidlow, bidclose, askopen, askhigh, asklow, askclose from ', self instrument, ' where (', self week asDbxString, ' < startdate) AND (startdate < ', self weekEnd asDbxString , ')') rows.
   ohlc := OneWeekData rows: (rows size) columns: 10.
   1 to: rows size do: [:row || newRow |
       newRow := ((rows at: row) values).  newRow := newRow copyWith: (((newRow at: 3) + (newRow at: 4) + (newRow at: 5)) / 3).
       ohlc atRow: row put: newRow ].

Maybe this real world example will help. As I said my usage is simple. SqueakDBX has worked very well for me.

Nice to hear that :)
 

I simply wrote the sql statement I wanted executed with my columns ordered as I wanted for the rows retrieved. If I remember correctly each rows values are when passed the "values" message return an Array which is what I pass to my Matrix.

If we aren't providing  the answers desired. Please provide more information to direct us. Mariano has been very helpful for any of my questions.

Jimmie


Thanks Jimmie