28 lines
785 B
Python
28 lines
785 B
Python
|
#!/usr/bin/env python3
|
||
|
|
||
|
from sqlalchemy import create_engine, select, MetaData, Table
|
||
|
from pprint import pprint
|
||
|
import os
|
||
|
|
||
|
db_user = os.getenv("db_user", default="cacert")
|
||
|
db_password = os.getenv("db_password", default="cacert")
|
||
|
db_host = os.getenv("db_host", "localhost")
|
||
|
db_port = os.getenv("db_port", "3306")
|
||
|
db_name = os.getenv("db_name", "cacert")
|
||
|
|
||
|
dsn = (
|
||
|
f"mariadb+mariadbconnector://{db_user}:{db_password}@{db_host}:{db_port}/{db_name}"
|
||
|
)
|
||
|
engine = create_engine(dsn)
|
||
|
|
||
|
metadata_obj = MetaData()
|
||
|
|
||
|
for table in ("emailcerts", "domaincerts", "orgemailcerts", "orgdomaincerts"):
|
||
|
certs_table = Table(table, metadata_obj, autoload_with=engine)
|
||
|
|
||
|
stmt = select(certs_table)
|
||
|
|
||
|
with engine.connect() as conn:
|
||
|
for row in conn.execute(stmt):
|
||
|
pprint(row)
|