From: Michael Tremer Date: Tue, 21 Jan 2025 14:24:28 +0000 (+0000) Subject: database: Allow to execute raw statements X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ebee7574ab5533fd54269d9e7dab210fd9ba24a9;p=pbs.git database: Allow to execute raw statements Signed-off-by: Michael Tremer --- diff --git a/src/buildservice/database.py b/src/buildservice/database.py index 353dc9a1..d173d76f 100644 --- a/src/buildservice/database.py +++ b/src/buildservice/database.py @@ -321,7 +321,7 @@ class Connection(object): # Mark it as deleted await session.delete(object) - async def _execute(self, stmt): + async def execute(self, stmt): """ Executes a statement and returns a result object """ @@ -340,7 +340,7 @@ class Connection(object): """ Fetches objects of the given type """ - result = await self._execute(stmt) + result = await self.execute(stmt) # Process the result in batches if batch_size: @@ -351,7 +351,7 @@ class Connection(object): yield object async def fetch_one(self, stmt): - result = await self._execute(stmt) + result = await self.execute(stmt) # Return exactly one object or none, but fail otherwise return result.scalar_one_or_none() @@ -378,7 +378,7 @@ class Connection(object): """ Returns the raw result after a SELECT statement """ - result = await self._execute(stmt) + result = await self.execute(stmt) # Process mappings result = result.mappings() @@ -390,7 +390,7 @@ class Connection(object): """ Returns exactly one row """ - result = await self._execute(stmt) + result = await self.execute(stmt) # Process mappings result = result.mappings()