<jupyter_start><jupyter_text>MySQL 테이블을 생성하고 데이터를 넣기<jupyter_code>import os

import pandas as pd

import MySQLdb
DATABASE_HOST = "localhost"  # "localhost" == "127.0.0.1"

DATABASE_USERNAME = os.environ.get("DATABASE_USERNAME", "YOUR_USERNAME")
DATABASE_PASSWORD = os.environ.get("DATABASE_PASSWORD", "<PASSWORD>")

DATABASE_NAME = "fastcampus_data_science_db"
connection = MySQLdb.connect(
    DATABASE_HOST,
    DATABASE_USERNAME,
    DATABASE_PASSWORD,
    DATABASE_NAME,
    charset='utf8',
)
connection

cursor = connection.cursor()
SQL_QUERY = """
    CREATE TABLE IF NOT EXISTS fastroom 
    (
        email varchar(255),
        phonenumber varchar(255),
        address varchar(255),
        deposit int,
        rent int
    );
"""

cursor.execute(SQL_QUERY)
SQL_QUERY = """
    SHOW TABLES;
"""

cursor.execute(SQL_QUERY)
cursor.fetchall()
SQL_QUERY = """
    SELECT *
    FROM fastroom;
"""

pd.read_sql(SQL_QUERY, connection)
# 지금까지 추가된 row 데이터 제거

# SQL_QUERY
SQL_QUERY = """
    DELETE FROM fastroom;
"""

cursor.execute(SQL_QUERY)
SQL_QUERY = """
    INSERT INTO fastroom (email, phonenumber, address, deposit, rent)
    VALUES (
        "<EMAIL>",
        "010-2220-5736",
        "서울시 강남구 논현1동 2-9 대기빌딩 1,4층",
        1000,
        50
    );
"""

cursor.execute(SQL_QUERY)
SQL_QUERY = """
    SELECT *
    FROM fastroom;
"""

pd.read_sql(SQL_QUERY, connection)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12428977272727272, 'fraction_numerical': 0.026988636363636364, 'mean_word_length': 3.444794952681388, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '384705', 'license': 'MIT', 'n_tokens_mistral': 597, 'n_tokens_neox': 589, 'n_words': 101, 'path': 'database/add-data-to-table.ipynb', 'repo_name': 'dobestan/pydata-101', 'size': '1422'}