[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [depictor/master] Change the vote_data table insert to use a non-hardcoded number of columns.



commit 95b542b4359b83bde545e5f548efcc1f704243b2
Author: Tom <tom@xxxxxxxxx>
Date:   Wed Oct 26 11:58:16 2016 -0500

    Change the vote_data table insert to use a non-hardcoded number of columns.
---
 write_website.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/write_website.py b/write_website.py
index 70edf3e..cd51b4f 100755
--- a/write_website.py
+++ b/write_website.py
@@ -124,8 +124,10 @@ def main():
 
 	insertValues = [unix_time(consensuses.values()[0].valid_after)]
 	createColumns = ""
+	insertQuestions = ""
 	for dirauth_nickname in CONFIG['historical_dirauths']:
 		createColumns += dirauth_nickname + "_known integer, " + dirauth_nickname + "_running integer, " + dirauth_nickname + "_bwauth integer, "
+		insertQuestions += ",?,?,?"
 		if dirauth_nickname in votes:
 			insertValues.append(data[dirauth_nickname]['known'])
 			insertValues.append(data[dirauth_nickname]['running'])
@@ -138,7 +140,7 @@ def main():
 	dbc.execute("CREATE TABLE IF NOT EXISTS vote_data(date integer, " + createColumns + " PRIMARY KEY(date ASC));")
 	dbc.commit()
 
-	dbc.execute("INSERT OR REPLACE INTO vote_data VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", insertValues)
+	dbc.execute("INSERT OR REPLACE INTO vote_data VALUES (?" + insertQuestions + ")", insertValues)
 	dbc.commit()
 
 	# Write out the updated csv file for the graphs



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits