import MySQLdb
dbconn=MySQLdb.connect(host='localhost',user='mscan',passwd='123456',db='mscan')
def dbinsert(tablename,domain,content,sqlmap=0):
	cur=dbconn.cursor()
	sql='insert into '+tablename+' (Domain,Content,Sqlmap) values (\''+domain+'\',\''+content+'\',\''+str(sqlmap)+'\')'
	cur.execute(sql)
	dbconn.commit()
	cur.close()
def dbselect():
	cur=dbconn.cursor()
	sql='select Id,Content from mscan_proxy where sqlmap=0 limit 1'
	cur.execute(sql)
	row=cur.fetchone()
	dbconn.commit()
	cur.close()
	return row
def dbupdate(Id):
	cur=dbconn.cursor()
	sql='update mscan_proxy set Sqlmap=1 where Id='+str(Id)
	cur.execute(sql)
	dbconn.commit()
	cur=dbconn.cursor()
def dbdelete(Id):
	cur=dbconn.cursor()
	sql='delete from mscan_proxy where Id='+str(Id)
	cur.execute(sql)
	dbconn.commit()
	cur=dbconn.cursor()
def dbselect_count():
	cur=dbconn.cursor()
	sql='select count(*) from mscan_proxy where sqlmap=0'
	cur.execute(sql)
	dbconn.commit()
	cur=dbconn.cursor()
