Skip to content

Commit

Permalink
SQL cursor execute changes
Browse files Browse the repository at this point in the history
  • Loading branch information
DogukanUrker committed Jan 17, 2024
1 parent 2e33bf6 commit 6909bc1
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions routes/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,31 @@ def user(userName):
match str(userName).lower() in str(users).lower():
case True:
message("2", f'USER: "{userName}" FOUND')
cursor.execute(f'select * from users where lower(userName) = "{userName}"')
cursor.execute(
"""select * from users where lower(userName) = ?""",
[(userName)],
)
user = cursor.fetchone()
connection = sqlite3.connect(DB_POSTS_ROOT)
cursor = connection.cursor()
cursor.execute(f'select views from posts where author = "{user[1]}"')
cursor.execute(
"""select views from posts where author = ?""",
[(user[1])],
)
viewsData = cursor.fetchall()
views = 0
for view in viewsData:
views += int(view[0])
cursor.execute(f'select * from posts where author = "{user[1]}"')
cursor.execute(
"""select * from posts where author = ?""",
[(user[1])],
)
posts = cursor.fetchall()
connection = sqlite3.connect(DB_COMMENTS_ROOT)
cursor = connection.cursor()
cursor.execute(
f'select * from comments where lower(user) = "{userName.lower()}"'
"""select * from comments where lower(user) = ?""",
[(userName.lower())],
)
comments = cursor.fetchall()
if posts:
Expand Down

0 comments on commit 6909bc1

Please sign in to comment.