drop some obsolete files
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
71d347632c
commit
2a4452e67f
@ -1,10 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
|
|
||||||
sv() {
|
|
||||||
cat pvec.sql | sed 's/%Y%/'$1'/' | sed 's/%M%/'$2'/' | sed 's/%D%/'$3'/' | psql -d udi-hottis
|
|
||||||
}
|
|
||||||
|
|
||||||
sv 2025 01 02
|
|
||||||
|
|
||||||
|
|
45
src/main.py
45
src/main.py
@ -1,45 +0,0 @@
|
|||||||
import psycopg
|
|
||||||
from loguru import logger
|
|
||||||
|
|
||||||
def main():
|
|
||||||
try:
|
|
||||||
conn = psycopg.connect()
|
|
||||||
logger.info("Database connection opened")
|
|
||||||
except Exception as e:
|
|
||||||
logger.error(f"Error when opening database connection {e}"(
|
|
||||||
return
|
|
||||||
|
|
||||||
try:
|
|
||||||
with conn.cursor(cursor_factory=psycopg.extras.DictCursor) as cursor:
|
|
||||||
select_stmt = psycopg.sql.SQL("""
|
|
||||||
SELECT ...
|
|
||||||
""")
|
|
||||||
cursor.execute(select_stmt, (...))
|
|
||||||
row = cursor.fetchone()
|
|
||||||
|
|
||||||
if not row:
|
|
||||||
logger.error(f"No data found")
|
|
||||||
return
|
|
||||||
|
|
||||||
value = row["bla"]
|
|
||||||
|
|
||||||
# calculation
|
|
||||||
insert_stmt = psycopg.sql.SQL("""
|
|
||||||
INSERT ...
|
|
||||||
""")
|
|
||||||
cursor.execute(insert_stmt, (...))
|
|
||||||
conn.commit()
|
|
||||||
|
|
||||||
logger.info(f"Data successfully written to database")
|
|
||||||
except Exception as e:
|
|
||||||
logger.error(f"Error when selecting or writing database {e}")
|
|
||||||
conn.rollback()
|
|
||||||
finally:
|
|
||||||
conn.close()
|
|
||||||
logger.info("Database connection closed")
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user