|
| 1 | +#!/usr/bin/python |
| 2 | + |
| 3 | +import griddb_python as griddb |
| 4 | +import sys |
| 5 | + |
| 6 | +factory = griddb.StoreFactory.get_instance() |
| 7 | + |
| 8 | +argv = sys.argv |
| 9 | + |
| 10 | +try: |
| 11 | + |
| 12 | + # Get GridStore object |
| 13 | + gridstore = factory.get_store(host=argv[1], port=int(argv[2]), cluster_name=argv[3], username=argv[4], password=argv[5]) |
| 14 | + |
| 15 | + # When operations such as container creation and acquisition are performed, it is connected to the cluster. |
| 16 | + gridstore.get_container("containerName") |
| 17 | + print("Connect to Cluster") |
| 18 | + |
| 19 | + # Create Collection |
| 20 | + conInfo = griddb.ContainerInfo(name="SamplePython_Info", |
| 21 | + column_info_list= |
| 22 | + [["id", griddb.Type.INTEGER], |
| 23 | + ["productName", griddb.Type.STRING], |
| 24 | + ["count", griddb.Type.INTEGER]], |
| 25 | + type=griddb.ContainerType.COLLECTION, |
| 26 | + row_key=True) |
| 27 | + |
| 28 | + col = gridstore.put_container(conInfo) |
| 29 | + print("Sample data generation: Create Collection name=SamplePython_Info") |
| 30 | + |
| 31 | + # Get container information |
| 32 | + # (1)Get container information |
| 33 | + containerInfor = gridstore.get_container_info("SamplePython_Info") |
| 34 | + |
| 35 | + # (2)Display container information |
| 36 | + print("Get ContainerInfo:\n name =", containerInfor.name) |
| 37 | + |
| 38 | + if (containerInfor.type == griddb.ContainerType.COLLECTION): |
| 39 | + print(" type=Collection") |
| 40 | + else: |
| 41 | + print(" type=Timeseries") |
| 42 | + |
| 43 | + print(" rowKeyAssigned=", containerInfor.row_key) |
| 44 | + |
| 45 | + count = len(containerInfor.column_info_list) |
| 46 | + print(" columnCount=", count) |
| 47 | + |
| 48 | + for i in range(0, count): |
| 49 | + print(" column (", containerInfor.column_info_list[i][0],",", containerInfor.column_info_list[i][1],")") |
| 50 | + print("success!") |
| 51 | + |
| 52 | +except griddb.GSException as e: |
| 53 | + for i in range(e.get_error_stack_size()): |
| 54 | + print("[", i, "]") |
| 55 | + print(e.get_error_code(i)) |
| 56 | + print(e.get_location(i)) |
| 57 | + print(e.get_message(i)) |
0 commit comments