-
Notifications
You must be signed in to change notification settings - Fork 0
/
createtable.py
58 lines (45 loc) · 1.46 KB
/
createtable.py
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import happybase as db
import convertjson as queryfy
def deleteTable(IP, tablename):
connection = db.Connection(IP)
table=connection.table(tablename)
connection.delete_table(tablename,disable=True)
#creates a table with 'tika' and 'ocr' column families
def createMyTable(IP,tablename):
connection = db.Connection(IP)
connection.create_table(
tablename,
{'tika': dict(),
'ocr': dict(),
}
)
connection.close()
def updateTable(IP,tablename,uniquerowkey,query):
connection = db.Connection(IP)
table=connection.table(tablename)
#print query
table.put(uniquerowkey,query) #put-eg: table.put('1234',{"tika:cf1":"value1","ocr:cf2":"val2"})
def printTable(IP,tablename):
connection = db.Connection(IP)
table=connection.table(tablename)
for key, data in table.scan():
print data
class readablestring(object):
def __init__(self, string):
self.string=string
def read(self):
return self.string
if __name__ == '__main__':
IP='10.1.94.57'
tablename='escorts_images_sha1_dev'
uniquerowkey=1
deleteTable(IP,tablename)
createMyTable(IP, tablename)
# jsonfile = open('/Users/asitangm/Desktop/out6.json', 'r') #json dumped by parser indexer
#
# for jsonstring in jsonfile:
# uniquerowkey+=1
# query = queryfy.create_query_from_json(readablestring(jsonstring))
# updateTable(IP,tablename,str(uniquerowkey),query)
#
#