I've got a python file which has a bunch of sql queries in it depending on the arguments that are being passed example would be like this:
if args.monitor == 'Argument One':
sql_query = """select a, b, c from tableA where a = 123"""
elif args.monitor == 'Argument Two':
sql_query = """select d, e, f from TableA where d = 456"""
elif ....
This continues on for about 10 different queries with different complexities.
Obviously this makes a mess of code, and to update and/or add SQL queries involves touching a lot of code. What I'd like to do is part the queries/arguments into some sort of dict. Is it possible to use a config file for this purpose where I could do something like the following?
[query]
Argument A = select a, b, c from tableA where a = 123
Argument B = select d, e, f from TableA where d = 456
And then call via ConfigParser. My concern is that some of the queries are quite long (10 lines max) so how would I represent that in a config file?
Or do I go the route of saving each query as ArgumentA.sql and then list the directory and if the argument matches then use that sql?
Has anyone approached a scenario like this before?