Project: A command-line insertion utility
We can now put together the elements of database programming that we have covered in this chapter to form a robust command-line insertion utility. For this project we want to create a program with the following functionality:
Runs from the command-line
Uses a flag system allowing for the
-h
flag for helpAllows the user to define the database being used
Allows the user to designate which user and password combination to use
Allows the user to ask for the tables available in a given database
Provides the user with the column structure of the table on demand
Validates user input for the given table of the selected database
Builds the database
INSERT
statement on-the-flyInserts the user input into the chosen table of the selected database
The necessary modules
Before we jump into coding, let us first assess which modules we need to import. The modules we need are listed next to our required functionality as follows. The need for MySQLdb
is understood.
Flag system...