singlestore-sql-validator 0.0.2__py3-none-any.whl → 0.1.0__py3-none-any.whl

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.4
2
2
  Name: singlestore-sql-validator
3
- Version: 0.0.2
3
+ Version: 0.1.0
4
4
  Summary: SQL grammar validator for SingleStore queries
5
5
  License: Apache License (2.0)
6
6
  License-File: LICENSE
@@ -21,6 +21,7 @@ Description-Content-Type: text/markdown
21
21
 
22
22
  # singlestore-sql-validator
23
23
 
24
+ *Attention*: The code in this repository is intended for experimental use only and is not fully tested, documented, or supported by SingleStore. Visit the SingleStore Forums to ask questions about this repository.
24
25
 
25
26
  `singlestore-sql-validator` is a Python library for validating SQL queries using the SingleStore Language Server (version 0.1.3 and later). It provides a convenient interface to check SQL syntax and semantics by communicating with a SingleStore language server instance over TCP or WebSocket (with optional TLS support).
26
27
 
@@ -37,7 +38,7 @@ Description-Content-Type: text/markdown
37
38
  Install via pip (after cloning or packaging):
38
39
 
39
40
  ```bash
40
- pip install sql-validator-python
41
+ pip install singlestore-sql-validator
41
42
  ```
42
43
 
43
44
  Or add to your `pyproject.toml` as a dependency.
@@ -0,0 +1,8 @@
1
+ sql_validator/__init__.py,sha256=kOc2HUl3MJuRXgfzu5H_HW3fjOD2pT6HsqI3qESs0aQ,340
2
+ sql_validator/connection.py,sha256=D03SOlasKF9lTSwroHFZo1mTY5l6HtmqdqjyI-YdupM,320
3
+ sql_validator/result.py,sha256=eTq1HrB6MN_ittZddl02iKWBhDK7_N0YVD-GejMYH0E,3365
4
+ sql_validator/validator.py,sha256=hFW-zH8Pe_bSilw8mqW2P_a1ghUpaQG3FeIWPdi4htc,14733
5
+ singlestore_sql_validator-0.1.0.dist-info/METADATA,sha256=QwRHybQufI08fLbEw3YbiUAgOvhjDU2LlhsQdSErEXg,4571
6
+ singlestore_sql_validator-0.1.0.dist-info/WHEEL,sha256=EGEvSphFYqXKs23-kQBeyNoJP1nrT8ZJKQoi5p5DYL8,88
7
+ singlestore_sql_validator-0.1.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
8
+ singlestore_sql_validator-0.1.0.dist-info/RECORD,,
@@ -113,6 +113,7 @@ class Validator(ABC):
113
113
  # Initialize connection states
114
114
  self._ws_connection = None
115
115
  self._ws_context = None
116
+ self._ws_loop = None
116
117
 
117
118
  if self.connection_mode == ConnectionMode.TCP:
118
119
  self._connection = self._create_tcp_connection()
@@ -240,9 +241,11 @@ class Validator(ABC):
240
241
  data_str = json.dumps(request)
241
242
  data_with_content_length = f"Content-Length: {len(data_str)}\r\n\r\n{data_str}"
242
243
  if self.connection_mode == ConnectionMode.TCP:
243
- # FIX: Double-check your server specification!
244
- # If it expects \r\n or a null-byte (\x00), swap '\n' out here.
245
- data_bytes = (data_with_content_length + "\n").encode("utf-8")
244
+ # LSP framing: the body must NOT be followed by any trailing bytes.
245
+ # An extra '\n' after the JSON payload causes the SingleStore
246
+ # language server to treat the connection as malformed and close
247
+ # it, breaking any subsequent validate() calls on the same socket.
248
+ data_bytes = data_with_content_length.encode("utf-8")
246
249
  # Send the data
247
250
  self._connection.sendall(data_bytes)
248
251
  # FIX: If using TLS, the underlying stream writer may need an explicit flush
@@ -255,10 +258,16 @@ class Validator(ABC):
255
258
  response = self._recv_all(self._connection)
256
259
  elif self.connection_mode in (ConnectionMode.WS, ConnectionMode.WSS):
257
260
  # WebSockets pass frames natively (newlines are not required as delimiters)
261
+ # Reuse a single event loop across calls so that the persistent
262
+ # websocket connection (which is bound to the loop that created it)
263
+ # stays valid for subsequent validate() invocations.
258
264
  try:
259
265
  loop = asyncio.get_running_loop()
260
266
  except RuntimeError:
261
- loop = asyncio.new_event_loop()
267
+ loop = self._ws_loop
268
+ if loop is None or loop.is_closed():
269
+ loop = asyncio.new_event_loop()
270
+ self._ws_loop = loop
262
271
  asyncio.set_event_loop(loop)
263
272
 
264
273
  response = loop.run_until_complete(
@@ -1,8 +0,0 @@
1
- sql_validator/__init__.py,sha256=kOc2HUl3MJuRXgfzu5H_HW3fjOD2pT6HsqI3qESs0aQ,340
2
- sql_validator/connection.py,sha256=D03SOlasKF9lTSwroHFZo1mTY5l6HtmqdqjyI-YdupM,320
3
- sql_validator/result.py,sha256=eTq1HrB6MN_ittZddl02iKWBhDK7_N0YVD-GejMYH0E,3365
4
- sql_validator/validator.py,sha256=oSY-jKit65cZnWsj7wNY9jOBHi3gg-KbK-_m8BsP9e8,14182
5
- singlestore_sql_validator-0.0.2.dist-info/METADATA,sha256=0ruEoG5vwPKKDajeMtQZGaOpmJkoydv07YQi9aWfKno,4352
6
- singlestore_sql_validator-0.0.2.dist-info/WHEEL,sha256=EGEvSphFYqXKs23-kQBeyNoJP1nrT8ZJKQoi5p5DYL8,88
7
- singlestore_sql_validator-0.0.2.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
8
- singlestore_sql_validator-0.0.2.dist-info/RECORD,,