Add a CLI argument for the location of the DB.

master
Simon Quigley 5 years ago
parent b8fbd5ef6c
commit 9068136a8e

@ -15,13 +15,14 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import argparse
import sqlite3
from modules.jenkins import JenkinsModule
ENABLED_MODULES = [JenkinsModule]
def sqlite_run(command, db=":memory:", return_output=False):
def sqlite_run(command, db, return_output=False):
"""Run the given SQLite command on our db
command must be a command that SQLite can run
@ -51,9 +52,17 @@ def main(module):
run.append(module.sqlite_setup())
run.append(module.sqlite_add())
run.append(module.sqlite_time_range(days=10))
print(sqlite_run(run, return_output=True))
# Use --db-location to pass to sqlite
print(sqlite_run(run, db=args.db_location, return_output=True))
if __name__ == "__main__":
# Parse CLI arguments
parser = argparse.ArgumentParser()
parser.add_argument("--db-location", type=str, default=":memory:",
help="Specify the location for the SQLite database")
args = parser.parse_args()
for module in ENABLED_MODULES:
main(module)

Loading…
Cancel
Save