Exercise: Read CSV File, Write into Sqlite3 Database

Requirement

Based on the outcome from Exercise: Read CSV File, write two programs to manipulate a Sqlite3 database.

  1. A program that creates a database schema. We need this as a separate program because we want to create the database once, and insert into it the contents of potentially many CSV files.

    $ python create-schema.py /tmp/mydb.sqlite
    
  2. Another program that inserts the contents of a CSV file into that database.

    $ python stock-to-db.py stock.csv /tmp/mydb.sqlite
    

Dependencies

cluster_python Python Programming: From Absolute Beginner to Advanced Productivity cluster_python_basics Python: The Language Fundamentals cluster_python_db Databases cluster_python_exercises Exercises cluster_python_exercises_csv CSV and Databases cluster_python_advanced Python: More Language Features python_basics_python_0160_boolean Boolean python_basics_python_0150_datatypes_overview Datatypes python_basics_python_0160_boolean->python_basics_python_0150_datatypes_overview python_basics_python_0120_helloworld Hello World python_basics_python_0110_blahblah Blahblah python_basics_python_0120_helloworld->python_basics_python_0110_blahblah python_basics_python_0130_syntax_etc Syntax etc. python_basics_python_0130_syntax_etc->python_basics_python_0120_helloworld python_basics_python_0139_commandline_argv Commandline Arguments (sys.argv) python_basics_python_0139_commandline_argv->python_basics_python_0130_syntax_etc python_basics_python_0125_running Running Python Programs python_basics_python_0139_commandline_argv->python_basics_python_0125_running python_basics_python_0150_datatypes_overview_compound Compound Datatypes python_basics_python_0150_datatypes_overview_compound->python_basics_python_0150_datatypes_overview python_basics_python_0193_while while Loops python_basics_python_0193_while->python_basics_python_0160_boolean python_basics_python_0170_if The if Statement python_basics_python_0193_while->python_basics_python_0170_if python_basics_python_0200_sequential_types Sequential Datatypes python_basics_python_0200_sequential_types->python_basics_python_0150_datatypes_overview_compound python_basics_python_0270_functions Functions python_basics_python_0270_functions->python_basics_python_0150_datatypes_overview python_basics_python_0140_variables Variables python_basics_python_0270_functions->python_basics_python_0140_variables python_basics_python_0125_running->python_basics_python_0120_helloworld python_basics_python_0225_range The range Function python_basics_python_0225_range->python_basics_python_0200_sequential_types python_basics_python_0220_for for Loops python_basics_python_0225_range->python_basics_python_0220_for python_basics_python_0150_datatypes_overview->python_basics_python_0140_variables python_basics_python_0140_variables->python_basics_python_0130_syntax_etc python_basics_python_0170_if->python_basics_python_0160_boolean python_basics_python_0220_for->python_basics_python_0193_while python_basics_python_0220_for->python_basics_python_0200_sequential_types python_db_sqlite3 DBAPI 2: sqlite3 python_db_dbapi2 DBAPI 2 python_db_sqlite3->python_db_dbapi2 python_db_dbapi2->python_basics_python_0220_for python_advanced_python_1010_generators_yield Iteration, Generators, And yield python_db_dbapi2->python_advanced_python_1010_generators_yield python_advanced_modules Modules and Packages python_db_dbapi2->python_advanced_modules python_exercises_csv_csv_db Exercise: Read CSV File, Write into Sqlite3 Database python_exercises_csv_csv_db->python_basics_python_0139_commandline_argv python_exercises_csv_csv_db->python_db_sqlite3 python_advanced_python_1010_generators_yield->python_basics_python_0200_sequential_types python_advanced_python_1010_generators_yield->python_basics_python_0270_functions python_advanced_python_1010_generators_yield->python_basics_python_0225_range python_advanced_python_1010_generators_yield->python_basics_python_0220_for