Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

tdbo - Tcl DataBase Object package

106 views
Skip to first unread message

nagu

unread,
May 14, 2013, 12:04:59 PM5/14/13
to
Friends,

Tcl DataBase Object (tdbo) provides a simple object oriented interface to database layer of an application. It is written based on incrTcl extension of Tcl. Currently it supports sqlite3 database. However, tdbo package is written in a generic way to plugin support for other databases. We will add support for other databases such as MySQL, Oracle etc., in future releases.

Source is available at:

git://github.com/nagarajanchinnasamy/tdbo.git

Please look at the README file and an example in demo folder for more details.

Please note that, I started developing it as I was learning sql programming couple of years back. So, I wouldn't claim that this is developed by a database expert.

Also, though its already being put in use in a real-time project, not all use cases are tested.

Will appreciate if you can try this out and send your feedback.



Thanks & Regards,
nagu.

Georgios Petasis

unread,
May 14, 2013, 12:52:42 PM5/14/13
to
Does this project have a different goal that TDBC, which is distributed
with Tcl core?

http://docs.activestate.com/activetcl/8.6/tdbc/index.html

George

nagu

unread,
May 14, 2013, 2:23:52 PM5/14/13
to
To be frank, my understanding is that tdbo would be one level of abstraction above tdbc.

By quick glance through the documentation and also based on my understanding on such APIs (for. e.g., Apache rivet's DIO package, PHPs PDO etc.), they require you to write the sql query when you prepare/execute the statement as per SQL language.

But, the approach with tdbo is to minimize (if not eliminate) the knowledge required about SQL languauge itself and view everything as (i?)tcl objects.

The writers of the business object definitions (e.g., Employee class derived from tdbo::DBObject) will need the knowledge of how a table/view is physically defined in the database. But, the users of those business object definitions will only need to know how to use a DBbject interface.

But, tdbo has limitations. It only provides a subset of access methods and their arguments(eg., get, mget, add, update and delete).... while, tdbc is more generic in nature.

So, I would say tdbo will be appealing to users who may not have (or have very minimal) knowledge of SQL language, but, look things in object oriented way.

Appreciate your questioning as I want to validate my own understanding on this subject. Please look into the example in demo folder too. I also do have more complex examples from a server side (in a typical web app) usage of tdbo package. I just need to figure out how to extract it from my project and publish. I am willing to share as much as possible :-)

Let me know if you see a value add from tdbo package.

Thanks & Regards,
nagu.

Georgios Petasis

unread,
May 14, 2013, 2:52:24 PM5/14/13
to
I see. If it is on top of TDBC, then why only limited to sqlite?
TDBC already abstracts over the various drivers, if you add an
abstraction over sql, won't this work with any database?

Also, is there a reason you haven't chosen TclOO?

(I am just asking, I consider Itcl obsolete...)

Regards,

George

nagu

unread,
May 14, 2013, 10:18:56 PM5/14/13
to
>
> I see. If it is on top of TDBC, then why only limited to sqlite?
>
> TDBC already abstracts over the various drivers, if you add an
>
> abstraction over sql, won't this work with any database?
>
>
>
> Also, is there a reason you haven't chosen TclOO?
>
>
>
> (I am just asking, I consider Itcl obsolete...)
>
>
>
> Regards,
>
>
>
> George

Hi George,

tdbo is written in such a way that the support for other databases can be plugged in easily. SQLite happens to be the first plugin written.

Currently tdbo is not on top of tdbc. But, it can easily be moved to. Its on the todo list.

Coming from C/C++ background, I found incrTcl a very natural move to pickup Tcl. I haven't learned TclOO yet. But, I thought it was meant for other OO frameworks (like itcl, snit etc) to be written onto than for direct usage (though there is nothing that stops you).... But, this subject, we can take it in a separate thread I guess :-)

Thanks & Regards,
nagu.

Donal K. Fellows

unread,
May 15, 2013, 10:56:35 AM5/15/13
to
On 15/05/2013 03:18, nagu wrote:
> Coming from C/C++ background, I found incrTcl a very natural move to
> pickup Tcl. I haven't learned TclOO yet. But, I thought it was meant
> for other OO frameworks (like itcl, snit etc) to be written onto than
> for direct usage (though there is nothing that stops you).... But,
> this subject, we can take it in a separate thread I guess :-)

One of the curious things about OO foundations is that they're also OO
systems in their own right (or at least it's very easy to make them be
that way). However, incrTcl 4 is indeed built on TclOO, and is also
properly part of any complete Tcl 8.6 distribution, so building on top
of that is just fine. (IIRC, itcl and TclOO are the strongest OO systems
on the C API front, but I might be flat wrong there.)

Adapting to use TDBC (esp. tdbc::sqlite) instead of SQLite shouldn't be
too hard. Adapting to other DBs... well, the real problem is that the
SQL dialects themselves vary quite a bit and TDBC doesn't do anything to
help with that (because it inhibits supporting other uses, alas;
supporting power-users was judged to be more critical than easing
trivial migrations). The TDBC system tries to make at least the Tcl side
of things be best-practice stuff though, so that the only problems are
in how to connect (not too hard, really) and how to write the SQL.

Donal.
--
Donal Fellows — Tcl user, Tcl maintainer, TIP editor.

nagu

unread,
May 18, 2013, 2:21:38 AM5/18/13
to
Thanks Donal for your inputs... As tdbo only uses a small (and mostly standard) part of SQL, I am hoping that building tdbo on top of tdbc shouldn't be very hard.

Regards,
nagu.
0 new messages