tessl install tessl/pypi-connectorx@0.4.0Load data from databases to dataframes, the fastest way.
Agent Success
Agent success rate when using this tile
86%
Improvement
Agent success rate improvement when using this tile compared to baseline
1.05x
Baseline
Agent success rate without this tile
82%
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.