Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import MySQLdb
- from sys import argv as sa
- dbname="passwords"
- project=sa[1]
- infile=sa[2]
- db = MySQLdb.connect(host="some.ip.tld", user="username", password="password")
- cur = db.cursor()
- try:
- cur.execute("create database " + str(dbname))
- except Exception as e:
- print e
- cur.execute("use " + str(dbname))
- try:
- cur.execute('CREATE TABLE '+str(project)+' (id INT NOT NULL AUTO_INCREMENT,email blob NOT NULL,user NOT NULL,domain blob NOT NULL,password blob NOT NULL,PRIMARY KEY (id));')
- except Exception as e:
- print e
- pass
- try:
- cur.execute('ALTER TABLE '+str(project)+' AUTO_INCREMENT = 1;')
- except Exception as e:
- print e
- pass
- db.commit()
- cur.close()
- db = MySQLdb.connect(host="some.ip.tld", user="username", password="password")
- #db = MySQLdb.connect(host="localhost", user="root")
- cur = db.cursor()
- try:
- cur.execute("use " + str(dbname))
- query='LOAD DATA LOCAL INFILE "'+infile+'" INTO TABLE '+str(project)+' FIELDS TERMINATED BY ":" (email, user, domain, password);'
- cur.execute(query)
- except Exception as e:
- print e
- pass
- db.commit()
- cur.close()
- print "Finished"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement