summaryrefslogtreecommitdiff
path: root/lib/db.py
diff options
context:
space:
mode:
authorPepper <pepper@scannerjammer.com>2015-10-06 23:05:16 -0400
committerPepper <pepper@scannerjammer.com>2015-10-06 23:05:16 -0400
commit7dd49caaee7adecaa1e628964bbe78dac459d7dc (patch)
tree845e0dc71cf46c1f10a5734d07305c4eaa9bce0e /lib/db.py
parent0240c4237013a3a80e575e8478fdaa73a68067a0 (diff)
added new tagging logic and the data route
Diffstat (limited to 'lib/db.py')
-rw-r--r--lib/db.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/db.py b/lib/db.py
index a236344..6a7e424 100644
--- a/lib/db.py
+++ b/lib/db.py
@@ -2,6 +2,7 @@
"""all database connections and logic goes here"""
from config import DB_HOST, DB_USER, DB_PASSWORD, DB_NAME
import time, sys
+import simplejson as json
from sqlalchemy import Column, Integer, LargeBinary, String, create_engine, sql
from sqlalchemy.ext.declarative import declarative_base
@@ -37,6 +38,11 @@ class Db(object):
))
self.Session = sessionmaker(bind=engine)
+ def search(self, **kwargs):
+ session = self.Session()
+ results = session.query(ImCmd).filter_by(**kwargs).all()
+ return map(lambda n: { "tag": n.tag, "data": json.loads(n.dataobj) }, results)
+
def insert_cmd(self, **kwargs):
try:
session = self.Session()