-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnosql.py
More file actions
26 lines (22 loc) · 789 Bytes
/
Copy pathnosql.py
File metadata and controls
26 lines (22 loc) · 789 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import sys
from database import Database
from router import make_app
def main(argv):
assert argv[0], 'Please specify the directory of the database'
db = Database(argv[0])
app = make_app(db)
# db.create_collection('fruits', overwrite=True)
# table = db.get_collection('fruits')
# table.insert_many([{'type': 'apple', 'price': [100, 11, 12]},
# {'type': 'banana', 'price': 100, 'nutrition': {'Vitamin_C': 100, 'Cal': 10}}])
app.run(debug=True, port=9020)
while True:
try:
print('Press Ctrl+C to exit and save.')
input()
except (EOFError,KeyboardInterrupt):
db.close()
print('Database saved.')
exit()
if __name__ == '__main__':
main(sys.argv[1:])