Skip to content

Commit

Permalink
Patched /tmp/tmp_n5ibaaf/sqli/dao/student.py
Browse files Browse the repository at this point in the history
  • Loading branch information
patched.codes[bot] committed Nov 11, 2024
1 parent 3331e4a commit 68397ee
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions sqli/dao/student.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,23 @@ async def get_many(conn: Connection, limit: Optional[int] = None,
q = 'SELECT id, name FROM students'
params = {}
if limit is not None:
q += ' LIMIT + %(limit)s '
params['limit'] = limit
q += ' LIMIT %s '
params = (limit,)
if offset is not None:
q += ' OFFSET + %(offset)s '
params['offset'] = offset
if params:
q += ' OFFSET %s '
params += (offset,)
else:
params = (offset,)
async with conn.cursor() as cur:
await cur.execute(q, params)
results = await cur.fetchall()
return [Student.from_raw(r) for r in results]

@staticmethod
async def create(conn: Connection, name: str):
q = ("INSERT INTO students (name) "
"VALUES ('%(name)s')" % {'name': name})
async with conn.cursor() as cur:
await cur.execute(q)


await cur.execute(
"INSERT INTO students (name) VALUES (%s)",
(name,)
)

0 comments on commit 68397ee

Please sign in to comment.