Code: Alles auswählen
class Execute(threading.Thread):
def __init__(self, job, ausschalter):
threading.Thread.__init__(self)
self.job = job
self.ausschalter = ausschalter
def run(self):
conn = pysql.connect("db.s3db", isolation_level=None)
cur = conn.cursor()
if not conn or not cur:
return
while True:
anweisung= self.job.get()
print os.linesep + str(anweisung)
if anweisung =='quit':
self.ausschalter.set()
break
if type(anweisung)== str:
try:
conn.execute(anweisung)
except pysql.Error, ex:
print os.linesep + str(ex)
if type(anweisung)==list:
strSql = anweisung[-1]
del anweisung[-1]
try:
conn.executemany(strSql, anweisung)
except pysql.Error, ex:
print os.linesep + str(ex)
return 'test'
cur.close()
conn.close()