From c08fc79fac75ccaab36d421f017eb43210d5f9d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=90=D0=BB=D0=B5=D0=B9?= =?UTF-8?q?=D0=BA=D0=B8=D0=BD?= Date: Tue, 8 Oct 2024 22:27:17 +0400 Subject: [PATCH] Database settings are configured. --- database/database.py | 9 +++++++++ models/models.py | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 database/database.py diff --git a/database/database.py b/database/database.py new file mode 100644 index 0000000..d88797d --- /dev/null +++ b/database/database.py @@ -0,0 +1,9 @@ +from sqlalchemy import create_engine +from sqlalchemy.ext.declarative import declarative_base +from sqlalchemy.orm import sessionmaker + +DATABASE_URL = "postgresql://postgres:postgres@localhost/price-builder" + +engine = create_engine(DATABASE_URL) +SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine) +Base = declarative_base() diff --git a/models/models.py b/models/models.py index 7a507a1..f3d56a8 100644 --- a/models/models.py +++ b/models/models.py @@ -1,5 +1,5 @@ from sqlalchemy import Column, Integer, String, Float -from database import Base +from database.database import Base class Laptop(Base): __tablename__ = "laptops"