Skip to content

Commit

Permalink
Merge pull request #20 from codeforberlin/update-sqlalchemy-dependencies
Browse files Browse the repository at this point in the history
Update SQLAlchemy and related dependencies
  • Loading branch information
k-nut authored Jun 24, 2024
2 parents 2a4546b + 60661d4 commit 866285e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
13 changes: 7 additions & 6 deletions app/crud.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import List, Optional

from sqlalchemy.orm import Session
from sqlalchemy.sql import text

from . import models
from .filters import SchoolFilter
Expand All @@ -26,26 +27,26 @@ def get_schools(db: Session, skip: int = 0, limit: int = 100, filter_params=None


def get_stats(db: Session):
response = db.execute("""select substring(id, 1, 2) as state, count(*) as count
response = db.execute(text("""select substring(id, 1, 2) as state, count(*) as count
from schools
group by state
order by state;""")
return list(response)
order by state;"""))
return [row._mapping for row in response]


def _get_states(db: Session):
return [state for state, in db.execute("select distinct(substring(id, 1, 2)) from schools;")]
return [state for state, in db.execute(text("select distinct(substring(id, 1, 2)) from schools;"))]


def _get_school_types(db: Session):
return [school_type for school_type, in
db.execute("select distinct(school_type) from schools where school_type is not null;")
db.execute(text("select distinct(school_type) from schools where school_type is not null;"))
]


def _get_legal_status(db: Session):
return [school_type for school_type, in
db.execute("select distinct(legal_status) from schools where legal_status is not null;")
db.execute(text("select distinct(legal_status) from schools where legal_status is not null;"))
]


Expand Down
3 changes: 1 addition & 2 deletions app/database.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import os

from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
from sqlalchemy.orm import sessionmaker, declarative_base


engine = create_engine(os.environ.get("DATABASE_URL"))
Expand Down
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
fastapi==0.65.2
GeoAlchemy2==0.8.4
psycopg2==2.8.4
GeoAlchemy2==0.15.1
psycopg2==2.9.9
Shapely==1.7.1
SQLAlchemy==1.3.10
SQLAlchemy==2.0.31

0 comments on commit 866285e

Please sign in to comment.