From 32e3ca5bb0fdf6001cda7b49bb9cd59322922152 Mon Sep 17 00:00:00 2001 From: "oluyemi.a.simbrellang.com" Date: Tue, 15 Apr 2025 15:01:58 +0100 Subject: [PATCH] progress on connecting db --- app/models/__init__.py | 1 + app/models/transactions.py | 25 +++++++++++++++++++++++++ wsgi.py | 2 +- 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 app/models/__init__.py create mode 100644 app/models/transactions.py diff --git a/app/models/__init__.py b/app/models/__init__.py new file mode 100644 index 0000000..f386329 --- /dev/null +++ b/app/models/__init__.py @@ -0,0 +1 @@ +from .transactions import Transaction \ No newline at end of file diff --git a/app/models/transactions.py b/app/models/transactions.py new file mode 100644 index 0000000..9d500d2 --- /dev/null +++ b/app/models/transactions.py @@ -0,0 +1,25 @@ +from app.extensions import db +from datetime import datetime, timezone + +class Transaction(db.Model): + __tablename__ = "transactions" + + id = db.Column( + db.Integer, + primary_key=True, + autoincrement=True, + ) + transaction_id = db.Column(db.String(50), nullable=False) + account_id = db.Column(db.String(50), nullable=True) + customer_id = db.Column(db.String(50), nullable=True) + type = db.Column(db.String(50), nullable=False) + channel = db.Column(db.String(50), nullable=False) + created_at = db.Column(db.DateTime, default=datetime.now(timezone.utc)) + updated_at = db.Column(db.DateTime, default=datetime.now(timezone.utc), onupdate=datetime.now(timezone.utc)) + + def __repr__(self): + return f'' + + @classmethod + def get_transaction_by_id(cls, transaction_id): + return cls.query.get(transaction_id) \ No newline at end of file diff --git a/wsgi.py b/wsgi.py index b59093d..f49c773 100644 --- a/wsgi.py +++ b/wsgi.py @@ -32,4 +32,4 @@ if __name__ != "__main__": wsgi_app = app # Start kafka in a thread - # threading.Thread(target=start_kafka_consumer, daemon=True).start() + threading.Thread(target=start_kafka_consumer, daemon=True).start()