|
15 | 15 | # |
16 | 16 | """ |
17 | 17 | Examples using the Query.py API |
18 | | -
|
19 | | -Sample data from the New Study tutorial on labkey.org: |
20 | | - https://www.labkey.org/Documentation/wiki-page.view?name=studySetupManual |
21 | | -
|
22 | 18 | """ |
23 | 19 | from labkey.api_wrapper import APIWrapper |
24 | 20 | from labkey.exceptions import ( |
|
34 | 30 |
|
35 | 31 | print("Create a server context") |
36 | 32 | labkey_server = "localhost:8080" |
37 | | -project_name = "ModuleAssayTest" # Project folder name |
| 33 | +container_path = 'Tutorials/HIV Study' # Full project/folder container path |
38 | 34 | context_path = "labkey" |
39 | | -api = APIWrapper(labkey_server, project_name, context_path, use_ssl=False) |
| 35 | +api = APIWrapper(labkey_server, container_path, context_path, use_ssl=False) |
40 | 36 |
|
41 | 37 | schema = "lists" |
42 | 38 | table = "Demographics" |
|
80 | 76 | print("Caught bad schema") |
81 | 77 |
|
82 | 78 | # catch SSL error |
83 | | -ssl_api = APIWrapper(labkey_server, project_name, context_path, use_ssl=True) |
| 79 | +ssl_api = APIWrapper(labkey_server, container_path, context_path, use_ssl=True) |
84 | 80 | try: |
85 | 81 | result = ssl_api.query.select_rows(schema, table) |
86 | 82 | print(result) |
|
89 | 85 |
|
90 | 86 |
|
91 | 87 | # catch bad context path |
92 | | -bad_api = APIWrapper(labkey_server, project_name, "", use_ssl=False) |
| 88 | +bad_api = APIWrapper(labkey_server, container_path, "", use_ssl=False) |
93 | 89 | try: |
94 | 90 | result = bad_api.query.select_rows(schema, table) |
95 | 91 | print(result) |
96 | 92 | except ServerNotFoundError: |
97 | 93 | print("Caught context path") |
98 | 94 |
|
99 | 95 | # catch bad folder path error |
100 | | -bad_api = APIWrapper(labkey_server, "bad_project_name", context_path, use_ssl=False) |
| 96 | +bad_api = APIWrapper(labkey_server, "bad_container_path", context_path, use_ssl=False) |
101 | 97 | try: |
102 | 98 | result = bad_api.query.select_rows(schema, table) |
103 | 99 | print(result) |
|
0 commit comments