MCPcopy Create free account
hub / github.com/piccolo-orm/piccolo / _run_in_existing_connection

Method _run_in_existing_connection

piccolo/engine/sqlite.py:741–767  ·  view source on GitHub ↗

This is used when a transaction is currently active.

(
        self,
        connection,
        query: str,
        args: Optional[list[Any]] = None,
        query_type: str = "generic",
        table: Optional[type[Table]] = None,
    )

Source from the content-addressed store, hash-verified

739 return await cursor.fetchall()
740
741 async def _run_in_existing_connection(
742 self,
743 connection,
744 query: str,
745 args: Optional[list[Any]] = None,
746 query_type: str = "generic",
747 table: Optional[type[Table]] = None,
748 ):
749 """
750 This is used when a transaction is currently active.
751 """
752 if args is None:
753 args = []
754 await connection.execute("PRAGMA foreign_keys = 1")
755
756 connection.row_factory = dict_factory
757 async with connection.execute(query, args) as cursor:
758 response = await cursor.fetchall()
759
760 if query_type == "insert" and self.get_version_sync() < 3.35:
761 # We can't use the RETURNING clause on older versions
762 # of SQLite.
763 assert table is not None
764 pk = await self._get_inserted_pk(cursor, table)
765 return [{table._meta.primary_key._meta.db_column_name: pk}]
766 else:
767 return response
768
769 async def run_querystring(
770 self, querystring: QueryString, in_pool: bool = False

Callers 2

run_querystringMethod · 0.95
run_ddlMethod · 0.95

Calls 2

get_version_syncMethod · 0.95
_get_inserted_pkMethod · 0.95

Tested by

no test coverage detected