summaryrefslogtreecommitdiffstats
path: root/schema
diff options
context:
space:
mode:
authorMark Weiman <mark.weiman@markzz.com>2017-03-01 07:46:20 +0100
committerLukas Fleischer <lfleischer@archlinux.org>2017-03-01 20:29:07 +0100
commitc19284c78364e9c1663d69a963b9b0a89fdb2852 (patch)
treed3fe017640328dddecdf5e036b12be31c37fc5a8 /schema
parent28f33e7bb1d1ecb1b52ae2b2d876438cd25e3662 (diff)
downloadaur-c19284c78364e9c1663d69a963b9b0a89fdb2852.tar.gz
aur-c19284c78364e9c1663d69a963b9b0a89fdb2852.tar.xz
gendummydata.py: Fix to make it less db specific
Sqlite3 does not support the MD5 function like MySQL does, instead of the database program hash the passwords, have Python's hashlib module do it instead. Signed-off-by: Mark Weiman <mark.weiman@markzz.com> Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Diffstat (limited to 'schema')
-rwxr-xr-xschema/gendummydata.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/schema/gendummydata.py b/schema/gendummydata.py
index 9dd2f455..373f82ea 100755
--- a/schema/gendummydata.py
+++ b/schema/gendummydata.py
@@ -9,6 +9,7 @@ usage: gendummydata.py outputfilename.sql
# package names. It generates the SQL statements to
# insert these users/packages into the AUR database.
#
+import hashlib
import random
import time
import os
@@ -170,9 +171,11 @@ for u in user_keys:
#
pass
+ h = hashlib.new('md5')
+ h.update(u.encode());
s = ("INSERT INTO Users (ID, AccountTypeID, Username, Email, Passwd)"
- " VALUES (%d, %d, '%s', '%s@example.com', MD5('%s'));\n")
- s = s % (seen_users[u], account_type, u, u, u)
+ " VALUES (%d, %d, '%s', '%s@example.com', '%s');\n")
+ s = s % (seen_users[u], account_type, u, u, h.hexdigest())
out.write(s)
log.debug("Number of developers: %d" % len(developers))
@@ -202,9 +205,9 @@ for p in list(seen_pkgs.keys()):
uuid = genUID() # the submitter/user
- s = ("INSERT INTO PackageBases (ID, Name, SubmittedTS, "
- "SubmitterUID, MaintainerUID, PackagerUID) VALUES (%d, '%s', %d, %d, %s, %s);\n")
- s = s % (seen_pkgs[p], p, NOW, uuid, muid, puid)
+ s = ("INSERT INTO PackageBases (ID, Name, SubmittedTS, ModifiedTS, "
+ "SubmitterUID, MaintainerUID, PackagerUID) VALUES (%d, '%s', %d, %d, %d, %s, %s);\n")
+ s = s % (seen_pkgs[p], p, NOW, NOW, uuid, muid, puid)
out.write(s)
s = ("INSERT INTO Packages (ID, PackageBaseID, Name, Version) VALUES "
@@ -303,7 +306,7 @@ for t in range(0, OPEN_PROPOSALS+CLOSE_PROPOSALS):
user = user_keys[random.randrange(0,len(user_keys))]
suid = trustedusers[random.randrange(0,len(trustedusers))]
s = ("INSERT INTO TU_VoteInfo (Agenda, User, Submitted, End,"
- " SubmitterID) VALUES ('%s', '%s', %d, %d, %d);\n")
+ " Quorum, SubmitterID) VALUES ('%s', '%s', %d, %d, 0.0, %d);\n")
s = s % (genFortune(), user, start, end, suid)
out.write(s)
count += 1