Autocomplete working in query_editor plugin
[unfold.git] / manifold / util / storage.py
diff --git a/manifold/util/storage.py b/manifold/util/storage.py
new file mode 100644 (file)
index 0000000..066993e
--- /dev/null
@@ -0,0 +1,29 @@
+from manifold.gateways      import Gateway
+from manifold.util.callback import Callback
+
+#URL='sqlite:///:memory:?check_same_thread=False'
+URL='sqlite:////var/myslice/db.sqlite?check_same_thread=False'
+
+class Storage(object):
+    pass
+    # We can read information from files, database, commandline, etc
+    # Let's focus on the database
+
+    @classmethod
+    def register(self, object):
+        """
+        Registers a new object that will be stored locally by manifold.
+        This will live in the 
+        """ 
+        pass
+
+class DBStorage(Storage):
+    @classmethod
+    def execute(self, query, user=None, format='dict'):
+        # XXX Need to pass local parameters
+        gw = Gateway.get('sqlalchemy')(config={'url': URL}, user=user, format=format)
+        gw.set_query(query)
+        cb = Callback()
+        gw.set_callback(cb)
+        gw.start()
+        return cb.get_results()