Providing unified interface through DBIx::Class

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Providing unified interface through DBIx::Class

Andreas Pronakis
This question might sound a bit silly as I'm sure that DBIx::Class has the DBI part at the front for a reason, however I thought I'd ask anyway.

While evaluating DBIx::Class a question was raised by a colleague: "Can we use DBIx::Class to connect to data servers other than a Database e.g. to a service proving data through a port in an X delimited or XML (or …) format?".  Since I am fairly new to DBIC I thought I'd post the question here.

The aim is to provide a uniformed Interface to developers for accessing data, irrespective of the type of backend he has to talk to, to get the data, all the developer needs to know is that they will get a resultset that they can use the same way as resultset retrieved using a DB.

So they can still call:
my $obj = $schema->resultset('CustomResultSet::Object')->find('my_id');
or use search() (obviously without any joins or other DB related \%attrs but we could provide our own custom ones).

Is this possible/worth exploring?

Does anyone know which parts of DBIC would/potentially need to be sub-classed to achieve this?

Has anyone attempted something like this before? If so how did they go about it and what was the outcome?



Thank you in advance
Andreas





_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@...
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Providing unified interface through DBIx::Class

Eden Cardim
On Tue, Jul 15, 2008 at 9:59 AM, Andreas Pronakis <[hidden email]> wrote:
> Is this possible/worth exploring?
>
> Does anyone know which parts of DBIC would/potentially need to be sub-classed to achieve this?
>
> Has anyone attempted something like this before? If so how did they go about it and what was the outcome?

Yes, you need to implement your own storage class and pass it to your
schema via My::Schema->storage_type, which currently defaults to
'::DBI'. You'll need knowledge about how the SQLA syntax tree works,
mimicking DBIx::Class::Storage::DBI should get you started. Good news
is, you won't need to implement the entire spec, just the bits you
need for your app, incrementally. I've sucessfully done this in order
to query the Facebook API, which provides data serialized as JSON.

--
edenc.vox.com

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@...
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Providing unified interface through DBIx::Class

Matt S Trout
In reply to this post by Andreas Pronakis
On Tue, Jul 15, 2008 at 05:59:23AM -0700, Andreas Pronakis wrote:

> This question might sound a bit silly as I'm sure that DBIx::Class has the DBI part at the front for a reason, however I thought I'd ask anyway.
>
> While evaluating DBIx::Class a question was raised by a colleague: "Can we use DBIx::Class to connect to data servers other than a Database e.g. to a service proving data through a port in an X delimited or XML (or …) format?".  Since I am fairly new to DBIC I thought I'd post the question here.
>
> The aim is to provide a uniformed Interface to developers for accessing data, irrespective of the type of backend he has to talk to, to get the data, all the developer needs to know is that they will get a resultset that they can use the same way as resultset retrieved using a DB.
>
> So they can still call:
> my $obj = $schema->resultset('CustomResultSet::Object')->find('my_id');
> or use search() (obviously without any joins or other DB related \%attrs but we could provide our own custom ones).
>
> Is this possible/worth exploring?
>
> Does anyone know which parts of DBIC would/potentially need to be sub-classed to achieve this?

Should live just as a subclass of DBIx::Class::Storage.

Multiple backends were always planned but I'm not entirely sure how easy
they'll be now, we may have crept more RDBMS-ish stuff in than we meant to.

I've no objection to giving you a branch to experiment with though.

--
      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
   Technical Director                    http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://chainsawblues.vox.com/            http://www.shadowcat.co.uk/servers/

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@...
Loading...