<jupyter_start><jupyter_text>Functions for querying baseball info database<jupyter_code># Import statements
import sqlite3
import pandas as pd
import project_path
import import_ipynb<jupyter_output><empty_output><jupyter_text>Database connection function<jupyter_code>def create_connection(db_file: str) -> sqlite3.Connection:
    '''
    Create a database connection to the SQLite database specified by the db_file.
    Returns connection object or None with printed error.
    ''' 
    conn = None
    try:
        conn = sqlite3.connect(db_file)
    except Error as e:
        print(e)

    return(conn)<jupyter_output><empty_output><jupyter_text>Get table names from SQL database connection<jupyter_code>def get_tables(db_conn: sqlite3.Connection):
    '''
    Returns list of tables in a database given the connection object to that database.
    '''
    cursor = db_conn.cursor()
    table_query = "SELECT name FROM sqlite_master WHERE type='table';"
    results = cursor.execute(table_query).fetchall()
    return(results)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08026440037771483, 'fraction_numerical': 0.003777148253068933, 'mean_word_length': 4.698924731182796, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '547662', 'license': 'MIT', 'n_tokens_mistral': 319, 'n_tokens_neox': 308, 'n_words': 88, 'path': 'Lib/sql_queries.ipynb', 'repo_name': 'ungersk1998/WhichPitch', 'size': '1059'}