Archive for the ‘SQL’ Category

Value of prepared statements

Dec 7 2009

There are several database wrapper libraries out there for your favourite web development languages. For instance, there’s PDO for PHP and DBI for Perl. What do these do? Well they give some handy functions that encapsulate away a lot of the dirty details of database work you shouldn’t have to worry about. For example, these allow you to use any database backend of your choice (MySQL, Postgres, sqllite, etc) and connect with them easily. Instead of building a messy DSN connection string, pass a couple of arguments and you’ve got yourself a useful database handle to perform database operations with.
Read more »

Posted by Eugene | Comment (1)

Stored Procedures in Postgres

Oct 2 2009

There are two schools of thought regarding stored procedures. On side for them, you’ll hear about the virtues of cross-language functionality (any language with a Postgres database wrapper can run the functions, saving re-writing in separate libraries), they’re fast (precompiled), they operate in transactions and you can specify varying amounts of permissions. On the side against them, you’ll hear about the difficulty debugging them due to caching issues, testing can be a pain in the butt and deployment isn’t all that fun when you’ve got clustered databases to worry about. I believe there is a use for stored procedures, and, when used correctly, can make for some modular goodness. Firstly, let’s take a look at a sample stored procedure.
Read more »

Article tags: ,
Posted by Eugene | Comment (1)