#!/usr/bin/env python
# encoding: utf-8
import sys, getopt
import string
import MySQLdb
import sys
import os
reload(sys)
sys.setdefaultencoding('utf-8')
if __name__ == '__main__':
opts,args = getopt.getopt(sys.argv[1:], 'hp:u:d:U:')
user="aaa"
passwd="bbb"
database="freeswitch"
url="xxx"
for op, value in opts:
if op == "-u":
user = value
print user
elif op == "-p":
passwd = value
print passwd
elif op =="-d":
database = value
print database
elif op =="-U":
url = value
print url
else:
print "wrong usage!\n -u user -p passwd -d database -U url"
sys.exit()
db = MySQLdb.connect(url, user,passwd, database, charset='utf8' )
cursor = db.cursor()
for i in range(1000,3000):
sql = 'insert into userinfo (username, password) values('
sqlall = sql + "'" + str(i) + "','123454321');"
print sqlall
cursor.execute(sqlall)
db.commit()
db.close()