Load data from databases to dataframes, the fastest way.
86
Quality
Pending
Does it follow best practices?
Impact
86%
1.04xAverage score across 10 eval scenarios
Build a database query optimizer that loads data from PostgreSQL using different transfer protocols based on dataset characteristics and network conditions.
You need to implement a query optimizer that intelligently selects transfer protocols when loading data from PostgreSQL. The optimizer should choose between binary and CSV protocols based on the size of the dataset and available network bandwidth.
Your implementation should:
The optimizer should select protocols based on these rules:
Implement a function with this signature:
def optimized_query(conn_str: str, query: str, bandwidth: str) -> tuple:
"""
Execute a query with optimized protocol selection.
Args:
conn_str: PostgreSQL connection string
query: SQL query to execute
bandwidth: Either "high" or "low" indicating network conditions
Returns:
A tuple of (DataFrame, protocol_used) where protocol_used is either "binary" or "csv"
"""
pass@generates
def optimized_query(conn_str: str, query: str, bandwidth: str) -> tuple:
"""
Execute a query with optimized protocol selection.
Args:
conn_str: PostgreSQL connection string
query: SQL query to execute
bandwidth: Either "high" or "low" indicating network conditions
Returns:
A tuple of (DataFrame, protocol_used) where protocol_used is either "binary" or "csv"
"""
passProvides high-performance database connectivity with protocol selection support.
Install with Tessl CLI
npx tessl i tessl/pypi-connectorxdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10