qodalis-cli-server-plugin-data-explorer-postgres 1.0.0b24__tar.gz → 1.0.0b25__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: qodalis-cli-server-plugin-data-explorer-postgres
3
- Version: 1.0.0b24
3
+ Version: 1.0.0b25
4
4
  Summary: PostgreSQL Data Explorer provider plugin for Qodalis CLI servers
5
5
  Project-URL: Homepage, https://github.com/qodalis-solutions/cli-server-python
6
6
  Project-URL: Repository, https://github.com/qodalis-solutions/cli-server-python
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "qodalis-cli-server-plugin-data-explorer-postgres"
7
- version = "1.0.0b24"
7
+ version = "1.0.0b25"
8
8
  description = "PostgreSQL Data Explorer provider plugin for Qodalis CLI servers"
9
9
  readme = { text = "", content-type = "text/plain" }
10
10
  license = "MIT"
@@ -29,8 +29,16 @@ class PostgresDataExplorerProvider(IDataExplorerProvider):
29
29
  """Execute a SQL query against the PostgreSQL database."""
30
30
  start = time.monotonic()
31
31
  conn: asyncpg.Connection | None = None
32
+ # Read-only sources (the default): a read-only transaction, always
33
+ # rolled back (getattr: older abstractions have no read_only option)
34
+ read_only = getattr(context.options, "read_only", True) is not False
32
35
  try:
33
36
  conn = await asyncpg.connect(self._connection_string)
37
+ if read_only:
38
+ await conn.execute("BEGIN READ ONLY")
39
+ # Only through a prepared statement (the extended protocol): it
40
+ # refuses several statements, so a hidden "COMMIT; ..." cannot end
41
+ # the read-only transaction
34
42
  stmt = await conn.prepare(context.query)
35
43
  attributes = stmt.get_attributes()
36
44
 
@@ -51,7 +59,8 @@ class PostgresDataExplorerProvider(IDataExplorerProvider):
51
59
  error=None,
52
60
  )
53
61
  else:
54
- status = await conn.execute(context.query, *( context.parameters or []))
62
+ await stmt.fetch(*( context.parameters or []))
63
+ status = stmt.get_statusmsg() or ""
55
64
  try:
56
65
  affected = int(status.split()[-1])
57
66
  except (ValueError, IndexError):
@@ -83,6 +92,11 @@ class PostgresDataExplorerProvider(IDataExplorerProvider):
83
92
  )
84
93
  finally:
85
94
  if conn is not None:
95
+ if read_only:
96
+ try:
97
+ await conn.execute("ROLLBACK")
98
+ except Exception:
99
+ pass
86
100
  await conn.close()
87
101
 
88
102
  async def get_schema_async(