<jupyter_start><jupyter_text>Titanic<jupyter_code>import pandas as pd
df = pd.read_csv('Titanic.csv')
df['Name'] = df['Name'].str.replace("'", "")
t_conn = sqlite3.connect('Titanic.sqlite3')
df.to_sql('Titanic', con=t_conn, if_exists='replace')
t_curs = t_conn.cursor()
t_curs.execute('PRAGMA table_info(Titanic);').fetchall()
create_titanic_table = """
  CREATE TABLE titanic_data (
    index SERIAL PRIMARY KEY,
    Survived INTEGER,
    Pclass INTEGER,
    Name TEXT,
    Sex TEXT,
    Age REAL,
    Siblings_Spouses_Aboard INTEGER,
    Parents_Children_Aboard INTEGER,
    Fare FLOAT
  );
"""
pg_curs2 = pg_conn.cursor()
pg_curs2.execute(create_titanic_table)
persons = t_curs.execute('SELECT * FROM Titanic;').fetchall()

for person in persons:
    insert_person = """
        INSERT INTO titanic_data
        (index, Survived, Pclass, Name, Sex, Age, Siblings_Spouses_Aboard, Parents_Children_Aboard, Fare)
        VALUES """ + str(person[0:]) + ';'
    pg_curs2.execute(insert_person)
pg_curs2.close()
pg_conn.commit()
pg_curs = pg_conn.cursor()  # Make a new cursor
pg_curs.execute('SELECT * FROM titanic_data;')
pg_persons = pg_curs.fetchall()
for person, pg_person in zip(persons, pg_persons):
    assert person == pg_person<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1305379746835443, 'fraction_numerical': 0.005537974683544304, 'mean_word_length': 4.966981132075472, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '654449', 'license': 'MIT', 'n_tokens_mistral': 487, 'n_tokens_neox': 464, 'n_words': 90, 'path': 'module2-sql-for-analysis/Elephant SQL-rpg&titanic.ipynb', 'repo_name': 'JohnMorrisonn/DS-Unit-3-Sprint-2-SQL-and-Databases', 'size': '1264'}