Commit 37fde94f authored by okhin's avatar okhin
Browse files

Add a save function to save a call in database

parent 808a09a0
Pipeline #10 skipped
......@@ -55,7 +55,7 @@ class Call(json.JSONEncoder):
def load(cls, callid, db):
results = db.execute('SELECT caller, callee, owner, callid, history, state FROM calls WHERE callid = ?;', (callid,))
results = db.execute('SELECT caller, callee, owner, callid, history FROM calls WHERE callid = ?;', (callid,))
result = results.fetchone()
object = cls(result[0], result[1], result[2])
......@@ -65,6 +65,14 @@ class Call(json.JSONEncoder):
return None
def save(self, db):
Save the Call to database.
db.execute('''INSERT OR REPLACE INTO calls (caller, callee, owner, callid, history)
VALUES (?, ?, ?, ?, ?)
''', (self.caller, self.callee, self.owner, self.callid, json.dumps(self.history)))
# We need a decorator to check if our query is authenticated.
# We will store an API key and SECRET in ur database, the client
# needs to have both of them.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment