aboutsummaryrefslogtreecommitdiff
path: root/scripts/database.py
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2015-08-17 18:35:12 +0200
committerKarel Kočí <cynerd@email.cz>2015-08-17 18:35:12 +0200
commit3fb56b4760b0485cf0872100f04b0a5a51f52e97 (patch)
treed974a7de099d2f241e639348f6dd37d3d2153531 /scripts/database.py
parentcfeae5ec0d9488b2a6e51feb909e4c981008bf16 (diff)
downloadlinux-conf-perf-3fb56b4760b0485cf0872100f04b0a5a51f52e97.tar.gz
linux-conf-perf-3fb56b4760b0485cf0872100f04b0a5a51f52e97.tar.bz2
linux-conf-perf-3fb56b4760b0485cf0872100f04b0a5a51f52e97.zip
Generated configuration is now fully stored to database
Managing configurations in files and in database could cause inconsistence. Adding all generated configurations to database allow us to clean project files without loosing data.
Diffstat (limited to 'scripts/database.py')
-rw-r--r--scripts/database.py24
1 files changed, 19 insertions, 5 deletions
diff --git a/scripts/database.py b/scripts/database.py
index 6a4d0a1..c4f0a60 100644
--- a/scripts/database.py
+++ b/scripts/database.py
@@ -19,7 +19,7 @@ def __git_commit__():
def __timestamp__():
return datetime.datetime.now().strftime('%y-%m-%d-%H-%M-%S')
-Config = collections.namedtuple('Config', 'id hash cfile') # Named tuple for configuration
+Config = collections.namedtuple('Config', 'id hash config') # Named tuple for configuration
Measure = collections.namedtuple('Measure', 'id conf_id mfile value') # Named tuple for measurement
class database:
@@ -78,21 +78,21 @@ class database:
ps(ds, cm)
return self.check_linuxgit()
- def add_configuration(self, hash, cfile, generator):
+ def add_configuration(self, hash, txtconfig, generator):
"Add configuration to database."
ps = self.db.prepare("""INSERT INTO configurations
- (hash, cfile, gtime, toolgit, linuxgit, generator)
+ (hash, config, gtime, toolgit, linuxgit, generator)
VALUES
($1, $2, $3, $4, $5, $6);
""")
gt = self.check_toolsgit()
lgt = self.check_linuxgit()
tm = datetime.datetime.now()
- ps(hash, cfile, tm, gt, lgt, generator)
+ ps(hash, txtconfig, tm, gt, lgt, generator)
def get_configration(self, hash):
"Return configration id for inserted hash."
- ps = self.db.prepare("""SELECT id, cfile FROM configurations
+ ps = self.db.prepare("""SELECT id, config FROM configurations
WHERE hash = $1""")
rtn = []
for dt in ps(hash):
@@ -140,3 +140,17 @@ class database:
for dt in ps():
rtn.append(Config(dt[0], dt[1], dt[2]))
return rtn
+
+ def add_configsort(self, configopt):
+ "Add configuration option to sorted list"
+ ps = self.db.prepare("""INSERT INTO configopt
+ (configopt) VALUES ($1)
+ """)
+ ps()
+
+ def get_configsort(self):
+ "Returns sorted list of all configuration options"
+ ps = self.db.prepare("""SELECT configopt FROM configopt
+ ORDER BY id ASC
+ """)
+ return ps()