Execute given PQL query using the Predibase PQL engine. Note that in order to query
a specific dataset you must set the corresponding connection with pql.set_connection.
Query for execution.
Select the first 10 rows from the Titanic dataset.
# First set connection
# Then execute query
df = pql.execute("""
# Check output of query
Larger Query Results
Communication between the Predibase SDK and server is constrained by network bandwidth.
Queries that produce a large amount of data can result in a large payload over the wire.
To avoid network issues, these queries should be split up into multiple queries that produce a smaller payload.
Here's an example of how to achieve this with data connections that use a SQL dialect supporting
- Store the following as string in a variable called
PREDICT Survived GIVEN
SELECT * FROM titanic
- Format the string, iteratively increasing the value of
# Limit the size of each query to 100K rows at a time
LIMIT = int(1e5)
dataset = pc.get_dataset("titanic", "file_uploads")
df = None
for offset in range(0, dataset.row_count, LIMIT):
current_query = query.format(LIMIT, offset)
df_results = pql.execute(current_query)
if df is None:
df = df_results
df = pd.concat([df, df_results])