Autocomplete working in query_editor plugin
[myslice.git] / manifold / util / storage.py
1 from manifold.gateways      import Gateway
2 from manifold.util.callback import Callback
3
4 #URL='sqlite:///:memory:?check_same_thread=False'
5 URL='sqlite:////var/myslice/db.sqlite?check_same_thread=False'
6
7 class Storage(object):
8     pass
9     # We can read information from files, database, commandline, etc
10     # Let's focus on the database
11
12     @classmethod
13     def register(self, object):
14         """
15         Registers a new object that will be stored locally by manifold.
16         This will live in the 
17         """ 
18         pass
19
20 class DBStorage(Storage):
21     @classmethod
22     def execute(self, query, user=None, format='dict'):
23         # XXX Need to pass local parameters
24         gw = Gateway.get('sqlalchemy')(config={'url': URL}, user=user, format=format)
25         gw.set_query(query)
26         cb = Callback()
27         gw.set_callback(cb)
28         gw.start()
29         return cb.get_results()