Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagecell
Path: blob/master/db.py
447 views
1
"""
2
Generic Database Adapter
3
4
The database is used for storing execute requests and
5
permalinks, as well as any extra logging required by
6
the web server and/or backend.
7
"""
8
9
10
class DB(object):
11
"""
12
Abstract base class for database adaptors.
13
"""
14
15
async def add(self, code, language, interacts):
16
"""
17
Add an entry to the database.
18
19
INPUT:
20
21
- ``code`` -- a string
22
23
- ``language`` -- a string
24
25
- ``interacts`` -- a string
26
27
OUTPUT:
28
29
- a string -- the identifier key for the entry
30
"""
31
raise NotImplementedError
32
33
async def get(self, key):
34
"""
35
Retrieve the entry from the database matching ``key``.
36
37
INPUT:
38
39
- ``key`` -- a string
40
41
OUTPUT:
42
43
- a tuple of three strings: the code, the language, the interact state.
44
"""
45
raise NotImplementedError
46
47