我有一个for循环,用于从sql DB中提取数据。我想为每行火灾找到一个单独的线程。在此示例中,我只是打印内容,但最终希望将脚本连接到freeswitch盒并拨打每个电话号码。
# SQL Query
sql_select_Query = "SELECT phone, ext, pin_number FROM phone"
cursor = mySQLconnection .cursor()
cursor.execute(sql_select_Query)
records = cursor.fetchall()
cursor.rowcount()
#Stores query variables
for row in records:
phone = str(row[0])
ext = str(row[1])
pin = str(row[2])
####FIRE MULTIPLE THREADS HERE
print("Phone = ", phone)
print("Extension = ", ext)
print("Pin = ", pin)
##############################
time.sleep(30)
cursor.close()