#!/usr/bin/python import os import glob os.system('mysql -u mysqlinst1 -pics421 -e \'use mydb1;\'') for i in glob.glob('/mnt/home/mysqlinst1/objects-1/*'): file = i useStatement = 'use mydb1;' loadStatement = 'load data local infile \'' + file + '\' into table Object fields terminated by \',\' lines terminated by \'\\n\';' command = 'mysql -u mysqlinst1 -pics421 -e "' + useStatement + ' ' + loadStatement + '"' print "Executing: " + command os.system(command)