我已經寫了eight source code
在名爲「8box」的表中向一個名爲「TA」的數據庫中插入了一些值。我打算同時運行這個eight source code
,然後這個eight source code
在一個小時內將數據保存在數據庫中。我編寫了用於收集數據的代碼,並且此eight source code
中的每一個都具有相同的語法以將值插入到「8box」將數據同時插入到多個應用程序中的一個表中使用MySQL
我想同時運行此eight source code
以便能夠收集數據。
我嘗試這樣做的結果是,數據庫只是充滿了來自第一源代碼值,沒有值從存儲在數據庫中
另一個來源我應該怎麼做?
waktu=time.strftime('%Y-%m-%d %H:%M:%S')
con = mdb.connect('localhost', 'root', 'qwer1234', 'TA');
with con:
cur = con.cursor()
#cur.execute("DROP TABLE IF EXISTS 8Box")
#cur.execute("CREATE TABLE 8Box (Name VARCHAR(25),Lot_Bid INT,Bid INT,Offer INT,Lot_Offer INT,Time DATETIME)")
cur.execute("INSERT INTO 8Box VALUES (%s,%s,%s,%s,%s,%s)",(name_new,lot_bid_1_new,bid_1_new,off_1_new,lot_off_1_new,waktu))
cur.execute("INSERT INTO 8Box VALUES (%s,%s,%s,%s,%s,%s)",(name_new,lot_bid_2_new,bid_2_new,off_2_new,lot_off_2_new,waktu))
cur.execute("INSERT INTO 8Box VALUES (%s,%s,%s,%s,%s,%s)",(name_new,lot_bid_3_new,bid_3_new,off_3_new,lot_off_3_new,waktu))
cur.execute("INSERT INTO 8Box VALUES (%s,%s,%s,%s,%s,%s)",(name_new,lot_bid_4_new,bid_4_new,off_4_new,lot_off_4_new,waktu))
cur.execute("INSERT INTO 8Box VALUES (%s,%s,%s,%s,%s,%s)",(name_new,lot_bid_5_new,bid_5_new,off_5_new,lot_off_5_new,waktu))
cur.execute("INSERT INTO 8Box VALUES (%s,%s,%s,%s,%s,%s)",(name_new,lot_bid_6_new,bid_6_new,off_6_new,lot_off_6_new,waktu))
cur.execute("INSERT INTO 8Box VALUES (%s,%s,%s,%s,%s,%s)",(name_new,lot_bid_7_new,bid_7_new,off_7_new,lot_off_7_new,waktu))
cur.execute("INSERT INTO 8Box VALUES (%s,%s,%s,%s,%s,%s)",(name_new,lot_bid_8_new,bid_8_new,off_8_new,lot_off_8_new,waktu))
cur.execute("INSERT INTO 8Box VALUES (%s,%s,%s,%s,%s,%s)",(name_new,lot_bid_9_new,bid_9_new,off_9_new,lot_off_9_new,waktu))
cur.execute("INSERT INTO 8Box VALUES (%s,%s,%s,%s,%s,%s)",(name_new,lot_bid_10_new,bid_10_new,off_10_new,lot_off_10_new,waktu))
所以你解除鎖定提交您的事務? – thebjorn
什麼是鎖? – Okta
mysql會鎖定您正在寫入但未提交的磁盤部分(在連接對象上調用commit方法),數據庫很可能會保留爲該表的其他任何寫入者鎖定。 (這將更容易顯示,如果你給我們一些代碼...) – thebjorn