1. Home
  2. Computing & Technology
  3. Python

Inserting Data Into a MySQL Database

By Al Lukaszewski, About.com

8 of 8

Executing the Program

With this class and function, one can easily add to MySQL tables on the fly. As it stands, the program expects input like this when it is executed:

>python insertmysql.py <id> <data>
If the program allowed for the database, user, and table to be defined at run-time (i.e., when the program is called), you then have a very flexible data insertion program that you can call from other programs.

While reading and writing is about all most people do with databases, if you would like to read more about MySQLdb, see the MySQLdb User's Guide at [link url=http://sourceforge.net/docman/display_doc.php?docid=32071&group_id=22307] SourceForge [/link].

8 of 8

Explore Python

More from About.com

  1. Home
  2. Computing & Technology
  3. Python
  4. Database Programming
  5. Python and MySQL - Inserting Python Data Into a MySQL Database - Executing the Python Program

©2008 About.com, a part of The New York Times Company.

All rights reserved.