[RAILS] Why not a DBIAdapter?

D

Daniel Berger

Hi all,

Well, since the rails mailing list idea was rejected, and since I
avoid IRC while at work, and I can never remember to recheck wiki
postings, I'm posting here. Yell at DHH if you don't like it. :p

I'd love to give rails a try. Unfortunately, we use Oracle here at
work and there isn't yet an Oracle adapter. I started creating one
using OCI8, but the more I look, the more I'm confused as to why there
isn't a "generic" adapter using DBI.

Looking at the AbstractAdapter class, I see a series of methods that
look like they need to be defined. Is there one that can't be handled
via DBI? I don't see one. They look generic to me, both in terms of
executing sql as well as retrieving metadata. If there are any that
require driver specific functions, can't we just call the appropriate
'func' method on the handle based on the driver name?

Plus, couldn't you somehow then take advantage of DBI's extra
features, like XML/XSLT/XSQL stuff?

What am I missing?

Regards,

Dan

PS - No, I don't care about the extra overhead from using DBI over
vendor specific drivers.
 
D

David Heinemeier Hansson

Well, since the rails mailing list idea was rejected, and since I
avoid IRC while at work, and I can never remember to recheck wiki
postings, I'm posting here. Yell at DHH if you don't like it. :p

To stay in touch with the wiki, I recommend looking into RSS. Nobody
can stay on top of a wiki by hand (or at least, I wouldn't want to).
RSS is proving a major benefit to the wikis of the world.
Plus, couldn't you somehow then take advantage of DBI's extra
features, like XML/XSLT/XSQL stuff?

What am I missing?

Rails actually started out using DBI, but to get the functionality I
wanted, I had to redo a bunch of things on the Rails side that was
already being done in DBI. And when I started doing some performance
testing, this double work proved to have a overhead of about 100%. So
at least for the MySQL adapter, I thought about how hard it would be to
do my "own" adapter to MySQL-ruby.

It proved to be remarkably easy. I think the adapter is around 80 lines
of code or something. Then Luke Holden did the SQLite and PostgreSQL
adapters in a few hours and that was pretty much the end of DBI for
Active Record. It was just too easy to do local adapters that didn't
have any of the DBI overhead and could do things the way Rails needed
them to be done.

Also, I think to keep my dependencies at a minimum. Active Record is
pretty self-contained. It even includes the Ruby-based Ruby-MySQL
adapter. So you only need to add the C-based bridges to get going with
other databases.

But. With all that said. It's not that I think DBI is a bad project or
that I would mind having a DBI adapter. DBI is great and if anyone
would rather do a DBI adapter than a set of local ones, I'd be happy to
accept it into Rails.

I am, however, concerned that doing a generic DBI adapter might
conflict with the auto-incrementation required by AR. There was talks
about how it was pretty hard even for ODBC.

Do my preference is for local adapters, but I would be willing to
accept a DBI adapter while those local ones were being made.
--
David Heinemeier Hansson,
http://www.rubyonrails.org/ -- Web-application framework for Ruby
http://www.instiki.org/ -- A No-Step-Three Wiki in Ruby
http://www.basecamphq.com/ -- Web-based Project Management
http://www.loudthinking.com/ -- Broadcasting Brain
http://www.nextangle.com/ -- Development & Consulting Services
 
D

David Morton

And of course, you can use your own "model" instead of ActiveRecord, if
you wish.
 
T

T. Sawyer

I'd love to give rails a try. Unfortunately, we use Oracle here at
work and there isn't yet an Oracle adapter. I started creating one
using OCI8, but the more I look, the more I'm confused as to why there
isn't a "generic" adapter using DBI.

I've asked on Rails FAQ why new adapters and not DBI. But no answer yet. I know one reason right off the bat. The #insert method returns the id key of the newly inserted record. DBI dosen't have a standard mechinism for this. I asked about it on DBI mailing list. There is disagreement on how to do, b/c keys can be more complex. I.e they can be multi-field keys and also auto-incremental or not. Plus lack of standard between backends. Active Record assumes you always have a field called id that is auto-incremental.

Two days ago I stripped ActiveRecord's adpater code out, improved upon it, and made it a separate library called ActiveDBA. I like it b/c its more straght foward than DBI (and also b/c of the key return on insert.) It could still use some improvement but it works well (I've been using it for another project) I wrote David to see if he was interested in its release. But he hasn't wrote back yet. Anyone else interested in such a thing? --essentially an alternative to DBI.
Looking at the AbstractAdapter class, I see a series of methods that
look like they need to be defined. Is there one that can't be handled
via DBI? I don't see one. They look generic to me, both in terms of
executing sql as well as retrieving metadata. If there are any that
require driver specific functions, can't we just call the appropriate
'func' method on the handle based on the driver name?

Indeed, I could write a ActiveDBA adapter for DBI in about a day + time to figure out how to deal with the id key across different DBDs. I need more input from DBI developers to work that out. Are you interested in such a thing?
Plus, couldn't you somehow then take advantage of DBI's extra
features, like XML/XSLT/XSQL stuff?

For?

T.
 
J

Jim Weirich

David Heinemeier Hansson said:
To stay in touch with the wiki, I recommend looking into RSS. Nobody
can stay on top of a wiki by hand (or at least, I wouldn't want to).
RSS is proving a major benefit to the wikis of the world.

Agreed! I just added the Rails/ActiveRecord/ActionPack wikis to my
aggregator, but noticed that the article links were incorrect.

Link provided by RSS: http://www.rubyonrails.org/rails/show/LavishPraise

Link that worked: http://www.rubyonrails.org/show/LavishPraise
 
J

Jamis Buck

David Heinemeier Hansson said:
To stay in touch with the wiki, I recommend looking into RSS. Nobody
can stay on top of a wiki by hand (or at least, I wouldn't want to).
RSS is proving a major benefit to the wikis of the world.

Since you mentioned it: I've tried a few RSS aggregators and found that
they seem to get in my way... I can't seem to find a way of using them
that doesn't feel clunky. I'm willing to admit that my own inexperience
with them is getting in my way, though, so here's the question:

Those of you that are "successfully" using RSS aggregators, which
aggregator(s) do you use, and how do you use it? (I don't need
instructions, I just want to know how you employ it, day-to-day).

Thanks!

- Jamis

--
Jamis Buck
(e-mail address removed)
http://www.jamisbuck.org/jamis

"I use octal until I get to 8, and then I switch to decimal."
 
S

Shashank Date

David Heinemeier Hansson said:
I am, however, concerned that doing a generic DBI adapter might
conflict with the auto-incrementation required by AR. There was talks
about how it was pretty hard even for ODBC.
^^^^^^^^^^^^^^^^^^^^^
Very true for ODBC as a generic solution. It is not that hard once we
choose to limit ourselves to Database specific solutions. I know, I know
that defeats the whole purpose ... but if you want to do it just to get
an idea of how powerful the framework is, I say don't worry too much
for the genericity.

Dan: is it possible to connect to your Oracle datasource using ODBC?
If it is, I would love to have you try out my ODBC adapter for AR. I
have already tried it on MS-Access and SQL Server 2000 and it works !

-- shanko
 
J

Josh Huber

Jamis Buck said:
Those of you that are "successfully" using RSS aggregators,
which aggregator(s) do you use, and how do you use it? (I don't
need instructions, I just want to know how you employ it,
day-to-day).

I read a bunch of RSS feeds inside Gnus. What's nice about that,
is it makes the feed appear like a newsgroup or an imap mailbox.
It's really no different, in terms of user-interface.
 
D

David Heinemeier Hansson

Since you mentioned it: I've tried a few RSS aggregators and found
that they seem to get in my way... I can't seem to find a way of using
them that doesn't feel clunky. I'm willing to admit that my own
inexperience with them is getting in my way, though, so here's the
question:

Those of you that are "successfully" using RSS aggregators, which
aggregator(s) do you use, and how do you use it? (I don't need
instructions, I just want to know how you employ it, day-to-day).

I felt the same way for a long time. Until I got NetNewsWire on the
Mac. That was the first RSS reader that really felt right.

I don't know what the state of affairs are on Linux, though. There's a
bunch of readers on Windows, though.
--
David Heinemeier Hansson,
http://www.rubyonrails.org/ -- Web-application framework for Ruby
http://www.instiki.org/ -- A No-Step-Three Wiki in Ruby
http://www.basecamphq.com/ -- Web-based Project Management
http://www.loudthinking.com/ -- Broadcasting Brain
http://www.nextangle.com/ -- Development & Consulting Services
 
A

Anders Engström

--T4sUOijqQbZv57TR
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

David Heinemeier Hansson said:
To stay in touch with the wiki, I recommend looking into RSS. Nobody
can stay on top of a wiki by hand (or at least, I wouldn't want to).
RSS is proving a major benefit to the wikis of the world. =20
[snip]
=20
Those of you that are "successfully" using RSS aggregators, which=20
aggregator(s) do you use, and how do you use it? (I don't need=20
instructions, I just want to know how you employ it, day-to-day).
=20

I've tried a number of aggregators (nttp/rss, raggle, amphetadesk,
centericq) but finally decided to handle RSS feeds as plain emails. I
tried fetchrss (java based) but didn't really like it. Finally I
stumbled upon rss2email[1]. I've set it up as a cron-job, and it works
perfect. The only "downside" is that it's a python hack <smile>.

On debian simply do 'apt-get install rss2email' and you're set.

[1]: http://www.aaronsw.com/2002/rss2email/

//Anders

--=20
=2E . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
=2E Anders Engstr=F6m (e-mail address removed)
=2E http://www.gnejs.net PGP-Key: ED010E7F
=2E [Your mind is like an umbrella. It doesn't work unless you open it.] =
=20


--T4sUOijqQbZv57TR
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFBI6rTuNLLbe0BDn8RAsNZAJ94m3LEZJ+kLqiXP3WRei4fzZ6tHgCfbWcH
mqjRO4I+QNYKzk9uv2RfG00=
=8l9V
-----END PGP SIGNATURE-----

--T4sUOijqQbZv57TR--
 
C

Carl Youngblood

On Windows I really like Feedreader--very lightweight and fast.
On Mac I like NetNewsWire but the lite version was a bit lacking in
features. One that looks okay that I haven't used too much is
NewsMac.
On Linux Straw looks pretty good, but I haven't tried it yet.

Carl
 
W

why the lucky stiff

Jamis said:
Those of you that are "successfully" using RSS aggregators, which
aggregator(s) do you use, and how do you use it? (I don't need
instructions, I just want to know how you employ it, day-to-day).

Like Josh and Anders mentioned, I think an e-mail-ish paradigm works
great for RSS. I've been using the bleeding edge Moz Thunderbird, which
lets you add an RSS account. It's excellent: notifies me when feeds are
updated, allows me to view either the RSS <description> summary or the
permalink URL in my preview pane.

_why
 
C

Carl Youngblood

Sorry I didn't answer your other question. With Feedreader, I just
leave it checking my feeds all day long. It spins a tray icon when
there is more news waiting. I usually read all the new headlines from
my feeds for 1/2 hour or so in the morning when I get to work and then
I glance briefly at any new ones that pop up during the day.
 
J

Jamis Buck

why said:
Like Josh and Anders mentioned, I think an e-mail-ish paradigm works
great for RSS. I've been using the bleeding edge Moz Thunderbird, which
lets you add an RSS account. It's excellent: notifies me when feeds are
updated, allows me to view either the RSS <description> summary or the
permalink URL in my preview pane.

_why

Wow, that's what I need, right there. That sounds like a perfect fit. I
already use Thunderbird... I guess the question now is: do I try to
install the bleeding edge, or do I wait until the next release?

Decisions, decisions...

Thanks all, for your feedback!

--
Jamis Buck
(e-mail address removed)
http://www.jamisbuck.org/jamis

"I use octal until I get to 8, and then I switch to decimal."
 
D

Dick Davies

* Jamis Buck said:
Since you mentioned it: I've tried a few RSS aggregators and found that
they seem to get in my way... I can't seem to find a way of using them
that doesn't feel clunky. I'm willing to admit that my own inexperience
with them is getting in my way, though, so here's the question:

Raggle (www.raggle.org) runs curses, drb or webrick interfaces to your
feeds, and is a pure ruby implemenentation - I found it as featureful as
netnewswire/straw/liferea et al (which are all basically the same interface)
but more versatile - little things like the curses interface is screen(1)
aware, so will pop up elinks/w3m/whatever in a new window. It also supports
opml or yaml feedlists, I managed to import my liferea feeds into it fine.

It's got a couple of rough edges, but the code is fairly legible, I'd certainly
recommend it.
 
E

Eric Hodel

--YZVh52eu0Ophig4D
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
Those of you that are "successfully" using RSS aggregators, which=20
aggregator(s) do you use, and how do you use it? (I don't need=20
instructions, I just want to know how you employ it, day-to-day).

Firefox + Sage.

RSS feeds are saved as bookmarks, Sage is a sidebar panel that checks
for updates and marks the bookmark with a red star. Clicking on the
bookmark gives you an HTML page generated from the RSS feed. You can
open permalinks in new tabs/windows as you like, or just read and
dismiss an entry if it supplies a decent summary.

http://sage.mozdev.org/

(It is even localized for jp-JP!)

--=20
Eric Hodel - (e-mail address removed) - http://segment7.net
All messages signed with fingerprint:
FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04


--YZVh52eu0Ophig4D
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (FreeBSD)

iD8DBQFBJAD5MypVHHlsnwQRAv5CAJ4j5bDI1ulbuQBfFAdXCp8FBu8RPACgkgw0
Fns0xuHoacA7c74s3pWPI9s=
=+/IS
-----END PGP SIGNATURE-----

--YZVh52eu0Ophig4D--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,156
Messages
2,570,878
Members
47,406
Latest member
ElizabetMo

Latest Threads

Top