Skip to content

Commit 0be6586

Browse files
committed
Update SQLAlchemy, refactor project.
1 parent 757529c commit 0be6586

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

sqlalchemy_tutorial/part1_connections/queries.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def fetch_job_listings(engine: Engine) -> Optional[List[dict]]:
2020
text(
2121
"SELECT job_id, agency, business_title, \
2222
salary_range_from, salary_range_to \
23-
FROM nyc_jobs ORDER BY RAND();"
23+
FROM nyc_jobs ORDER BY RAND() LIMIT 10;"
2424
)
2525
)
2626
rows = [dict(row) for row in result.fetchall()]

sqlalchemy_tutorial/part3_relationships/orm.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def create_new_user(session: Session, user: User) -> User:
4141
:return: Optional[User]
4242
"""
4343
try:
44-
user_query = session.query(User).all()
44+
user_query = session.query(User).filter(User.username == user.username).first()
4545
if user_query is None:
4646
session.add(user) # Add the user
4747
session.commit() # Commit the change

0 commit comments

Comments
 (0)