benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf a9f33074-7bb9-5fe5-a765-489a372fd106

Problem

Answer published by the source. Consult the official source to check your work against its answer.

complete prompt

import warnings
import sqlite3
import pandas as pd


def task_func(db_path, query, warn_large_dataset=True):
    """
    Fetches data from an SQLite database using the provided database path and SQL query.
    This function will issue a warning of "The data contains more than 10000 rows." when this condition is met.

    Parameters:
    - db_path (str): The file path to the SQLite database from which data needs to be fetched.
    - query (str): The SQL query string used to retrieve data from the specified database.
    - warn_large_dataset (bool, optional): A boolean flag that, when set to True, triggers a 
      warning if the retrieved dataset has more than 10,000 rows. Default is True.

    Returns:
    - pandas.DataFrame: A DataFrame containing the data fetched from the database.

    Requirements:
    - sqlite3
    - pandas
    - warnings

    Raises:
    - Exception: If any error occurs during database connection, SQL query execution, or data 
      fetching. The error message provides details about the issue, starting with "Error fetching data from the database: ".

    Example:
    >>> data = task_func('/path/to/sqlite.db', 'SELECT * FROM table_name')
    >>> print(data)
        column1  column2
    0         1        4
    1         2        5
    2         3        6
    """

instruct prompt

Fetches data from an SQLite database using the provided database path and SQL query. This function will issue a warning of "The data contains more than 10000 rows." when this condition is met.
The function should raise the exception for: Exception: If any error occurs during database connection, SQL query execution, or data fetching. The error message provides details about the issue, starting with "Error fetching data from the database: ".
The function should output with:
    pandas.DataFrame: A DataFrame containing the data fetched from the database.
You should write self-contained code starting with:

Code

import warnings
import sqlite3
import pandas as pd
def task_func(db_path, query, warn_large_dataset=True):

code prompt

Code

import warnings
import sqlite3
import pandas as pd
def task_func(db_path, query, warn_large_dataset=True):

entry point

task_func

libs

  • sqlite3
  • pandas
  • warnings

Discussion

Discussion

No discussion posts on this page yet. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

See answer Answer published by the source

Artifacts

Code, notes and reproducible work shared by participants. Files are served from a separate origin.

No artifacts on this page yet. Share reproducible code or notes in a contribution. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

Source and history

Official source

initial import