git-interface: Do not use rowcount

Avoid using Cursor.rowcount to obtain the number of rows returned by a
SELECT statement as this is not guaranteed to be supported by every
database engine.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
This commit is contained in:
Lukas Fleischer 2016-08-04 21:00:50 +02:00
parent ecbf32f0cc
commit 27631f1157
2 changed files with 11 additions and 7 deletions

View file

@ -40,10 +40,11 @@ cur = conn.execute("SELECT Users.Username, Users.AccountTypeID FROM Users " +
"WHERE SSHPubKeys.PubKey = ? AND Users.Suspended = 0",
(keytype + " " + keytext,))
if cur.rowcount != 1:
row = cur.fetchone()
if not row or cur.fetchone():
exit(1)
user, account_type = cur.fetchone()
user, account_type = row
if not re.match(username_regex, user):
exit(1)