How can I use DBD::Proxy with DBIx::Class?

I need to get a database connection through a firewall, and also limit what queries can be run. DBD::Proxy seems to be the perfect solution for this. However, I'm currently using DBIx::Class, and can't figure out how to hook them together.

In particular, DBD::Proxy doesn't take SQL; it takes particular named queries. But DBIx::Class doesn't seem to have a way to invoke those named queries.

This is inside a Catalyst-based webapp.

Answers


DBD::Proxy does take SQL. It allows for named queries as a convenience.

There is no convenient way to use DBIx::Class with DBD::Proxy named queries, since the purpose of the DBIx::Class Object-Relational Mapper (ORM) is to present an object-oriented view of SQL's Data Manipulation Language (DML) statements. The named query feature of DBD::Proxy is not a DML statement, so DBIx::Class does not have feature that suit your needs: passing a literal string directly to the prepare() function of your DBD::Proxy driver.

Some inconvenient ways:

  1. Don't use DBIx::Class. Just do it in DBI. You could use Catalyst::Model::DBI, or plain DBI + catalyst::Model::Adaptor + your own model class.

  2. Don't use named queries. This means that if you were planning to use named queries as a way to control access to the database, then you'll need to move the query authorization logic into the code that makes the call to the database inside your controller or model, depending on how you built your application.


Need Your Help

Modally presented UIViewController hides status bar, but doesn't show it again on dismiss

ios objective-c uiviewcontroller modalviewcontroller

So I have a view controller modalVC that I am instantiating from a storyboard and presenting modally via [self presentViewController:modalVC animated:YES completion:nil].