From 94998caa6727b0cadfaa71a273bb72d3052a0c3f Mon Sep 17 00:00:00 2001 From: KOSASIH Date: Thu, 8 Aug 2024 14:15:59 +0700 Subject: [PATCH] Create get_contracts.py --- .../contract-sphere-db/queries/get_contracts.py | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 projects/ContractSphere/data_storage/contract-sphere-db/queries/get_contracts.py diff --git a/projects/ContractSphere/data_storage/contract-sphere-db/queries/get_contracts.py b/projects/ContractSphere/data_storage/contract-sphere-db/queries/get_contracts.py new file mode 100644 index 000000000..241ceef32 --- /dev/null +++ b/projects/ContractSphere/data_storage/contract-sphere-db/queries/get_contracts.py @@ -0,0 +1,9 @@ +from sqlalchemy import create_engine +from contract_sphere_db.models import Contract + +engine = create_engine('postgresql://user:password@localhost/contract_sphere_db') + +def get_contracts(): + with engine.connect() as conn: + result = conn.execute(Contract.select()) + return [dict(row) for row in result]