You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Marcel Ferrari edited this page Feb 10, 2023
·
4 revisions
The query function is used to execute a query that returns table data. It takes a single argument, the query string, and returns the result as a pandas DataFrame.
Warning: executing SQL statements that do not return any data raises an error.
Function
defquery(query: str) ->pd.DataFrame:
""" Execute query that returns table data. Parameters: - query (str): SQL query to be executed Returns: - pd.DataFrame: result of the query """
Example:
# Connect to the databasedb=PandaSQLiteDB("example.sql")
# Execute a query to get all data from the "my_table" tableresult=db.query("SELECT * FROM my_table")
print(result.head())