Skip to content

Python SDK Migration

qql_intercept.py wraps the qdrant-client Python SDK at the HTTP layer, captures all REST API calls, and converts them to QQL using qql-go convert. Use it to migrate existing Python code to QQL.

Install dependencies
uv venv .venv && source .venv/bin/activate uv pip install qdrant-client
Print converted QQL to stdout
python3 sdks/python/qql_intercept.py your_script.py
Save to .qql file
python3 sdks/python/qql_intercept.py your_script.py -o output.qql

Given ingest.py:

from qdrant_client import QdrantClient
from qdrant_client.models import PointStruct
client = QdrantClient("localhost", port=6333)
client.upsert(
collection_name="docs",
points=[
PointStruct(id=1, payload={"text": "hello"}, vector=[0.1, 0.2, 0.3]),
PointStruct(id=2, payload={"text": "world"}, vector=[0.4, 0.5, 0.6]),
]
)
client.search("docs", query_vector=[0.1, 0.2, 0.3], limit=5)

Running the interceptor:

Run interceptor
python3 sdks/python/qql_intercept.py ingest.py -o output.qql

Produces output.qql:

INSERT INTO docs VALUES {'id': 1, 'text': 'hello', 'vector': {'': [0.1, 0.2, 0.3]}}
INSERT INTO docs VALUES {'id': 2, 'text': 'world', 'vector': {'': [0.4, 0.5, 0.6]}}
QUERY [0.1, 0.2, 0.3] FROM docs LIMIT 5

The interceptor captures any operation that QdrantClient makes via HTTP:

  • upsertINSERT INTO ... VALUES
  • search / query_pointsQUERY ... FROM
  • recommendQUERY RECOMMEND WITH (...)
  • scrollSCROLL FROM
  • retrieveSELECT * FROM ... WHERE id = ...
  • deleteDELETE FROM ... WHERE
  • create_collectionCREATE COLLECTION
  • create_payload_indexCREATE INDEX ON
  • set_payloadUPDATE ... SET PAYLOAD
Migration workflow
Step 1: Intercept and convertSection titled “Step 1: Intercept and convert”
python3 sdks/python/qql_intercept.py ingest.py -o output.qql
Step 2: Validate the outputSection titled “Step 2: Validate the output”
qql-go convert --validate output.qql
Step 3: Review and adjust as neededSection titled “Step 3: Review and adjust as needed”
Step 4: Execute with qql-goSection titled “Step 4: Execute with qql-go”
qql-go execute output.qql