-2

Im going to make a program that build SQL like queries based on settings.

Basically you have queries that are in an initial state and based on these settings the queries will at application start be built to fit the settings stored in what ever format.

So a method takes in the queries and return new queries based on settings.

I need some help on how these settings are stored. What is typical? to store settings in a file(ini, conf) or in a SQL DB?

  • Have you considered using SQLite? – dan04 Oct 28 '16 at 21:39
  • 4
    Possible duplicate of What is the preferred way to store application configurations? – gnat Oct 28 '16 at 21:49
  • just for the sake of these settings? I think SQL would be easiest since you wont have to create a parser to parse al kinds of lines. – wandapong Oct 28 '16 at 21:49
  • 3
    Damn you kids today with your sql, json, and xml. In my day we used ini files and we were happy to let some one else write the parser. Now get off my lawn! – candied_orange Oct 28 '16 at 22:34
  • 1
    There is no typical. – whatsisname Oct 29 '16 at 4:24
1

Where you choose to store configuration should be based on the purpose and the editor.

If the user chooses the settings and there is an installed client program, opt for a per-client INI file or registry settings.

For universal settings you can opt for server based files or database.

Configuration stored in a database tends to be simpler i.e. just key value pairs. A configuration file can be quite sophisticated if you want it to be, especially if you use XML.

On your application, be careful about sending a large number of nearly identical queries to the database. It flushes the SQL cache and kills performance.

0

In Java applications I simply use good old Properties class that write to and reads from plain text files with KEY=VALUE format.

DOWNLOAD_PATH=/home/user/download/
COMPANY_CODE=01
PRODUCT_CATEGORY=DAIRY
...

I guess most programming languages have a similar class that reads and writes values from a flat file given a key, and let's you define a default value if the property is not set.

Regarding the person who said SQL was better for this kind of startup vonfiguration: remeber a connection string or where to find the SQLite file other that a default location is something that should be in a conf file even before trying to connect to any database.

Also flat files have the advantage that are editable with any file editor. That's why Unix/Linux conf files are flat files.

Not the answer you're looking for? Browse other questions tagged or ask your own question.