query: Query,
params: Optional[Params] = None,
prepare: Optional[bool] = None,
+ row_factory: Optional[RowFactory] = None,
) -> "Cursor":
"""Execute a query and return a cursor to read its results."""
- cur = self.cursor()
+ cur = self.cursor(row_factory=row_factory)
return cur.execute(query, params, prepare=prepare)
def commit(self) -> None:
query: Query,
params: Optional[Params] = None,
prepare: Optional[bool] = None,
+ row_factory: Optional[RowFactory] = None,
) -> "AsyncCursor":
- cur = await self.cursor()
+ cur = await self.cursor(row_factory=row_factory)
return await cur.execute(query, params, prepare=prepare)
async def commit(self) -> None:
cur = conn.execute("select 12, 22")
assert cur.fetchone() == (12, 22)
+ cur = conn.execute("select 1, 2, 1, 2", row_factory=lambda cur: set)
+ assert cur.fetchone() == {1, 2}
+
def test_str(conn):
assert "[IDLE]" in str(conn)
cur = await aconn.execute("select 12, 22")
assert await cur.fetchone() == (12, 22)
+ cur = await aconn.execute("select 1, 2, 1, 2", row_factory=lambda cur: set)
+ assert await cur.fetchone() == {1, 2}
+
async def test_str(aconn):
assert "[IDLE]" in str(aconn)