Ed Leafe wrote:
> On Oct 2, 2009, at 6:46 PM, Ricardo Aráoz wrote:
>
>> I can see that ds = dabo.db.dDataSet() returns a dataset object, but I
>> wasn't able to find out how to define it's structure and generally
>> work
>> with it.
>
>
> A dabo.db.dDataSet is simply a subclass of tuple. A record is best
> represented as a Python dict, with column names as keys and values as
> the, well, values. A set of records is a tuple of these dicts, where
> every record has the same keys and same data types for each key value.
> The dDataSet class wraps that with some additional capabilities.
>
> To create one, it's pretty straightforward: create a tuple (or even a
> list) of dicts, and pass that to the dDataSet constructor. E.g.:
>
> recs = ({"foo": 1, "bar": "something"},
> {"foo": 2, "bar": "else"})
> ds = dabo.db.dDataSet(recs)
You could also go ahead and create a sqlite table on an in-memory database.
{{{
import dabo
con = dabo.db.connect(dbType="sqlite", Database=":memory:")
cur = con.cursor()
cur.execute("create table test (field1 char, field2 int)")
cur.execute("insert into test (field1, field2) values ('test', 1)")
}}}
And you could even make a bizobj off of it (to ease data binding):
{{{
biz = dabo.biz.dBizobj(con, Datasource="test", KeyField="field2", ...)
biz.requery()
}}}
Paul
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/[email protected]