Browse Source

cmd_acc: use connection to commit call of stored procedures

Daniel-Constantin Mierla 2 years ago
parent
commit
2e40deee29
1 changed files with 6 additions and 4 deletions
  1. 6 4
      kamcli/commands/cmd_acc.py

+ 6 - 4
kamcli/commands/cmd_acc.py

@@ -240,8 +240,9 @@ def acc_cdrs_generate(ctx):
     """Run SQL stored procedure to generate CDRS"""
     ctx.vlog("Run SQL stored procedure to generate CDRS")
     e = create_engine(ctx.gconfig.get("db", "rwurl"))
-    e.execute("call kamailio_cdrs()")
-    e.execute("commit")
+    with e.connect() as c:
+        c.execute("call kamailio_cdrs()")
+        c.commit()
 
 
 @cli.command(
@@ -418,5 +419,6 @@ def acc_cdrs_generate(ctx):
         "Run SQL stored procedure to rate the CDRS and generate the costs"
     )
     e = create_engine(ctx.gconfig.get("db", "rwurl"))
-    e.execute("call kamailio_rating()")
-    e.execute("commit")
+    with e.connect() as c:
+        c.execute("call kamailio_rating()")
+        c.commit()