git-importer/lib/test_exporter.py

27 lines
677 B
Python
Raw Permalink Normal View History

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()
2022-10-26 15:49:14 +02:00
with db.cursor() as cur:
cur.execute(
"SELECT * from revisions where package=%s ORDER BY commit_time",
2022-10-26 15:49:14 +02:00
(self.package,),
)
data = {"revisions": []}
for row in cur.fetchall():
data["revisions"].append(DBRevision(db, row).as_dict())
yaml.dump(data, sys.stdout, default_flow_style=False)