from sqlalchemy import text


def find_user(cursor, user_id):
    cursor.execute(f"SELECT * FROM users WHERE id = {user_id}")  # cotterpin:expect
    return cursor.fetchone()


def find_by_name(connection, name):
    return connection.execute(text("SELECT * FROM users WHERE name = '%s'" % name))  # cotterpin:expect


def delete(cursor, table, key):
    cursor.execute("DELETE FROM " + table + " WHERE id = ?", (key,))  # cotterpin:expect
