This is an automated email from the ASF dual-hosted git repository.

gstein pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/steve.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 28a9c6d  switch to asfpy.db via .open_database()
28a9c6d is described below

commit 28a9c6d7a87229f6d43d9aae28dbe21a5d36f736
Author: Greg Stein <[email protected]>
AuthorDate: Sat Dec 20 03:32:36 2025 -0600

    switch to asfpy.db via .open_database()
---
 v3/queries.yaml      |  4 ++++
 v3/steve/election.py | 15 +++++----------
 2 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/v3/queries.yaml b/v3/queries.yaml
index fb573eb..bf7ab41 100644
--- a/v3/queries.yaml
+++ b/v3/queries.yaml
@@ -25,6 +25,10 @@
 
 election:
     c_salt_mayvote: UPDATE mayvote SET salt = ? WHERE _ROWID_ = ?
+    c_create: |
+        INSERT INTO election
+          (eid, title, owner_pid, authz, open_at, close_at)
+        VALUES (?, ?, ?, ?, ?, ?)
     c_open: |
         UPDATE election
         SET salt = ?, opened_key = ?, open_at = unixepoch('now')
diff --git a/v3/steve/election.py b/v3/steve/election.py
index e0bbd51..0b705b4 100644
--- a/v3/steve/election.py
+++ b/v3/steve/election.py
@@ -407,22 +407,17 @@ class Election:
     def create(
         cls, db_fname, title, owner_pid, authz=None, open_at=None, 
close_at=None
     ):
-        # Open in autocommit
-        conn = sqlite3.connect(db_fname, isolation_level=None)
+        ### Open in autocommit??
+        db = cls.open_database(db_fname)
+
         while True:
             eid = crypto.create_id()
             try:
-                conn.execute(
-                    'INSERT INTO election'
-                    ' (eid, title, owner_pid,'
-                    '  authz, open_at, close_at)'
-                    ' VALUES (?, ?, ?, ?, ?, ?)',
-                    (eid, title, owner_pid, authz, open_at, close_at),
-                )
+                db.c_create.perform(eid, title, owner_pid,
+                                    authz, open_at, close_at)
                 break
             except sqlite3.IntegrityError:
                 _LOGGER.debug('EID conflict(!!) ... trying again.')
-        conn.close()
         _LOGGER.info(f'Created election[E:{eid}]')
 
         return cls(db_fname, eid, op='Opening NEW')

Reply via email to