Skip to content

Commit

Permalink
Update database.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Nneji123 authored Jan 7, 2024
1 parent 17c8768 commit e6aa2e6
Showing 1 changed file with 0 additions and 45 deletions.
45 changes: 0 additions & 45 deletions api/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ async def create_db_and_tables():
await conn.run_sync(SQLModel.metadata.create_all)


# def get_db():
# with Session(engine) as session:
# yield session




async def create_town_and_people(db: Session):
Expand Down Expand Up @@ -65,43 +60,3 @@ async def create_town_and_people(db: Session):

return created_towns, created_people

# async def connect_to_db():
# await database.connect()

# async def close_db_connection():
# await database.disconnect()

# def create_db_and_tables():
# engine = create_engine(settings.DATABASE_URI, echo=True, connect_args={"check_same_thread": False})
# SQLModel.metadata.create_all(engine)

# async def get_db() -> Session:
# async with database.transaction():
# yield Session()

# async def create_town_and_people(db: Session):
# town_data = [
# {"name": "Town A", "population": 10000, "country": "Country A"},
# {"name": "Town B", "population": 15000, "country": "Country B"},
# # Add more towns as needed
# ]

# created_towns = []
# for town_info in town_data:
# town = TownCreate(**town_info)
# created_town = await create_town(db, town)
# created_towns.append(created_town)

# people_data = [
# {"name": "Alice", "age": 30, "town_id": created_towns[0].id},
# {"name": "Bob", "age": 25, "town_id": created_towns[1].id},
# # Assign people to towns created above, adjust town_id as needed
# ]

# created_people = []
# for person_info in people_data:
# person = PersonCreate(**person_info)
# created_person = await create_person(db, person)
# created_people.append(created_person)

# return created_towns, created_people

0 comments on commit e6aa2e6

Please sign in to comment.