From a9651e3e4307e2f0a053710c74a616896a11266f Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Sun, 3 May 2020 16:55:55 -0700 Subject: [PATCH] import_realm: Use cursor.execute correctly. Signed-off-by: Anders Kaseorg --- zerver/lib/import_realm.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zerver/lib/import_realm.py b/zerver/lib/import_realm.py index 0e9764748c..38a16a0036 100644 --- a/zerver/lib/import_realm.py +++ b/zerver/lib/import_realm.py @@ -345,8 +345,8 @@ def allocate_ids(model_class: Any, count: int) -> List[int]: """ conn = connection.cursor() sequence = idseq(model_class) - conn.execute("select nextval('%s') from generate_series(1,%s)" % - (sequence, str(count))) + conn.execute("select nextval(%s) from generate_series(1, %s)", + [sequence, count]) query = conn.fetchall() # Each element in the result is a tuple like (5,) conn.close() # convert List[Tuple[int]] to List[int]