"""
Return a new cursor to send commands and queries to the connection.
"""
- format = Format.BINARY if binary else Format.TEXT
if not row_factory:
row_factory = self.row_factory
+
+ cur: Union[Cursor[Any], ServerCursor[Any]]
if name:
- return ServerCursor(
- self, name=name, format=format, row_factory=row_factory
- )
+ cur = ServerCursor(self, name=name, row_factory=row_factory)
else:
- return Cursor(self, format=format, row_factory=row_factory)
+ cur = Cursor(self, row_factory=row_factory)
+
+ if binary:
+ cur.format = Format.BINARY
+
+ return cur
def execute(
self,
"""
Return a new `AsyncCursor` to send commands and queries to the connection.
"""
- format = Format.BINARY if binary else Format.TEXT
if not row_factory:
row_factory = self.row_factory
+
+ cur: Union[AsyncCursor[Any], AsyncServerCursor[Any]]
if name:
- return AsyncServerCursor(
- self, name=name, format=format, row_factory=row_factory
- )
+ cur = AsyncServerCursor(self, name=name, row_factory=row_factory)
else:
- return AsyncCursor(self, format=format, row_factory=row_factory)
+ cur = AsyncCursor(self, row_factory=row_factory)
+
+ if binary:
+ cur.format = Format.BINARY
+
+ return cur
async def execute(
self,
self,
connection: ConnectionType,
*,
- format: Format = Format.TEXT,
row_factory: RowFactory[Row],
):
self._conn = connection
- self.format = format
+ self.format = Format.TEXT
self._adapters = adapt.AdaptersMap(connection.adapters)
self._row_factory = row_factory
self.arraysize = 1
connection: "Connection[Any]",
name: str,
*,
- format: pq.Format = pq.Format.TEXT,
row_factory: RowFactory[Row],
):
- super().__init__(connection, format=format, row_factory=row_factory)
+ super().__init__(connection, row_factory=row_factory)
self._helper: ServerCursorHelper["Connection[Any]", Row]
self._helper = ServerCursorHelper(name)
self.itersize: int = DEFAULT_ITERSIZE
connection: "AsyncConnection[Any]",
name: str,
*,
- format: pq.Format = pq.Format.TEXT,
row_factory: RowFactory[Row],
):
- super().__init__(connection, format=format, row_factory=row_factory)
+ super().__init__(connection, row_factory=row_factory)
self._helper: ServerCursorHelper["AsyncConnection[Any]", Row]
self._helper = ServerCursorHelper(name)
self.itersize: int = DEFAULT_ITERSIZE