Split the database config into 2 sections

This commit is contained in:
Stephan Kulow 2022-10-17 19:50:25 +02:00
parent 74fd937732
commit 88322fffae
4 changed files with 13 additions and 5 deletions

View File

@ -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

View File

@ -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

10
db.py
View File

@ -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)
)
""",
)

View File

@ -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)