views:

141

answers:

1

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.

+1  A: 

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.

Len Jaffe
That pretty much confirms what I expected. I unfortunately can't just move the access control to the app, because the goal is to protect the database against compromise of the Internet-accessible web servers.
derobert