Rename Exporter to TestExporter to make it more obvious

This commit is contained in:
Stephan Kulow
2022-11-02 07:39:04 +01:00
parent a8dfd80fdd
commit 9de0d6e6c5
2 changed files with 4 additions and 3 deletions

25
lib/test_exporter.py Normal file
View File

@@ -0,0 +1,25 @@
import sys
import yaml
from lib.db import DB
from lib.db_revision import DBRevision
class TestExporter:
""""Helper class to export data from production DB for tests"""
def __init__(self, package):
self.package = package
def run(self):
db = DB()
with db.cursor() as cur:
cur.execute(
"SELECT * from revisions where package=%s ORDER BY project,rev",
(self.package,),
)
data = {"revisions": []}
for row in cur.fetchall():
data["revisions"].append(DBRevision(row).as_dict(db))
yaml.dump(data, sys.stdout, default_flow_style=False)