Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Storing SQL Queries within a Configuration file?

A general question on what everyone's opinion is on storing SQL queries within a configuration file?

Is this just another bike shed?

Cheers, Ben

like image 361
Ben Crowhurst Avatar asked Mar 17 '10 12:03

Ben Crowhurst


2 Answers

No. never. Seriously ;) Cleaning up that here at the moment.

Try looking at BLToolkit - stores them in attributes right on the abstract class they dynamically generate the whole accessing code under. Same like using it in the config file, but without writing or seeing the stupid DAL code.

like image 199
TomTom Avatar answered Oct 12 '22 13:10

TomTom


Doesn't sound so bad to me, provided it meets the requirements.

Are you trying to allow the customer to see and edit the queries?

Are you trying to make it easier for development/testing?

I certainly prefer this to embedding the queries in code.

But there is a risk that this file will bloat with a myriad of slightly different queries (SORT ASCENDING, SORT DESCENDING, SUM(col1) + SUM(col2), SUM(col1) + SUM(col3), etc.)

like image 42
Timothy Avatar answered Oct 12 '22 13:10

Timothy