-
Notifications
You must be signed in to change notification settings - Fork 0
/
patchdb.py
executable file
·52 lines (46 loc) · 1.83 KB
/
patchdb.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python
from sqlalchemy import create_engine, MetaData, Table, Column, \
Integer, String, Date
import datetime
import sophie
class PatchDB():
""" Class containing database of patches for one RPM
distribution/release/arch
"""
def __init__(self, distribution, release, arch):
self.distribution = distribution
self.release = release
self.arch = arch
db_name = "_".join((self.distribution,
self.release,
self.arch,
"patch.db"))
self.database = create_engine("".join(('sqlite:///', db_name)),
echo=False)
self.metadata = MetaData(self.database)
self.patch_table = Table('patch', self.metadata,
Column('key_num', Integer, primary_key=True),
Column('patch_name', String(100)),
Column('srpm_name', String(100)),
Column('status', Integer),
Column('date', Date),
)
def first_population(self):
self.patch_table.create()
key_count = 0
patch_list = sophie.retrieve_patches(self.distribution,
self.release,
self.arch)
patches = list()
for patch in patch_list:
patches.append({'key_num': key_count,
'patch_name': patch[1],
'srpm_name': patch[0],
'status': 0,
'date': datetime.date.today()})
key_count += 1
patch_insertion = self.patch_table.insert()
patch_insertion.execute(patches)
if __name__ == "__main__":
Mageia_Db = PatchDB("Mageia", "cauldron", "x86_64")
Mageia_Db.first_population()