forked from griddb/python_client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFetchRowsWithDataFrame.py
More file actions
executable file
·47 lines (38 loc) · 1.36 KB
/
FetchRowsWithDataFrame.py
File metadata and controls
executable file
·47 lines (38 loc) · 1.36 KB
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
#!/usr/bin/python
import griddb_python as griddb
import sys
import pandas
factory = griddb.StoreFactory.get_instance()
argv = sys.argv
blob = bytearray([65, 66, 67, 68, 69, 70, 71, 72, 73, 74])
containerName = "SamplePython_FetchRows"
update = False
try:
# Get GridStore object
gridstore = factory.get_store(host=argv[1], port=int(argv[2]), cluster_name=argv[3], username=argv[4], password=argv[5])
# Create Collection
conInfo = griddb.ContainerInfo(containerName,
[["name", griddb.Type.STRING],
["status", griddb.Type.BOOL],
["count", griddb.Type.LONG],
["lob", griddb.Type.BLOB]],
griddb.ContainerType.COLLECTION, True)
col = gridstore.put_container(conInfo)
print("Create Collection name=", containerName)
# Put rows
rows = pandas.DataFrame([["name01", True, 1, blob], ["name02", False, 2, blob]])
col.put_rows(rows)
print("Put rows with DataFrame")
# Fetch rows
query = col.query("select *")
rs = query.fetch(update)
print("Fetch rows with DataFrame")
result = rs.fetch_rows()
print(result)
print("Success!")
except griddb.GSException as e:
for i in range(e.get_error_stack_size()):
print("[", i, "]")
print(e.get_error_code(i))
print(e.get_location(i))
print(e.get_message(i))