-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbootstrap.py
More file actions
executable file
·35 lines (27 loc) · 823 Bytes
/
bootstrap.py
File metadata and controls
executable file
·35 lines (27 loc) · 823 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
27
28
29
30
31
32
33
34
35
#!/usr/bin/env python
import rethinkdb as rdb
import json
from tqdm import tqdm
import os
db_host = ''
try:
db_host = os.environ["DB_HOST"]
except:
db_host = 'localhost'
r = rdb.RethinkDB()
r.connect( db_host, 28015 ).repl()
try:
r.db_create("fanuc").run()
except rdb.errors.ReqlOpFailedError:
print("database exists")
try:
r.db("fanuc").table_create("ib30_error").run()
except rdb.errors.ReqlOpFailedError:
print("table exists")
data = json.load(open('./asset/fanuc_error.json'))
for elem in tqdm(data):
r.db("fanuc").table("ib30_error").insert(elem).run()
r.db("fanuc").table("ib30_error").index_create('number').run()
r.db("fanuc").table("ib30_error").index_wait("number").run()
r.db("fanuc").table("ib30_error").index_create('title').run()
r.db("fanuc").table("ib30_error").index_wait("title").run()