From 88322fffae89d332fac14be4722353c426742555 Mon Sep 17 00:00:00 2001 From: Stephan Kulow Date: Mon, 17 Oct 2022 19:50:25 +0200 Subject: [PATCH] Split the database config into 2 sections --- config.py | 2 +- database.ini | 5 ++++- db.py | 10 ++++++++-- revision.py | 1 - 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/config.py b/config.py index 2f893e2..f052d59 100644 --- a/config.py +++ b/config.py @@ -1,7 +1,7 @@ from configparser import ConfigParser -def config(filename="database.ini", section="postgresql"): +def config(filename="database.ini", section="production"): # create a parser parser = ConfigParser() # read config file diff --git a/database.ini b/database.ini index e956eea..67d072a 100644 --- a/database.ini +++ b/database.ini @@ -1,4 +1,7 @@ # For local users you can simply rely on the UNIX permissions. # For remote databases you have to add host, user and password -[postgresql] +[production] database=imported_git + +[test] +database=imported_git_test diff --git a/db.py b/db.py index a9a48e1..07d35e5 100644 --- a/db.py +++ b/db.py @@ -52,8 +52,14 @@ class DB: """, "INSERT INTO scheme (version) VALUES(1)", """ CREATE TABLE revisions ( - id SERIAL PRIMARY KEY, - package VARCHAR(255) NOT NULL + id SERIAL PRIMARY KEY, + project VARCHAR(255) NOT NULL, + package VARCHAR(255) NOT NULL, + rev VARCHAR(255) NOT NULL, + unexpanded_srcmd5 VARCHAR(255) NOT NULL, + commit_time timestamp NOT NULL, + userid VARCHAR(255) NOT NULL, + comment VARCHAR(255) ) """, ) diff --git a/revision.py b/revision.py index add95a1..f64cb98 100644 --- a/revision.py +++ b/revision.py @@ -19,7 +19,6 @@ class Revision: self.rev = int(xml.get("rev")) # Replaced in check_expanded self.srcmd5 = xml.find("srcmd5").text - self.version = xml.find("version").text time = int(xml.find("time").text) self.time = datetime.datetime.fromtimestamp(time)