-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbulkquery.py
More file actions
43 lines (40 loc) · 830 Bytes
/
bulkquery.py
File metadata and controls
43 lines (40 loc) · 830 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
36
37
38
39
40
41
42
43
import json
def bulk_operation(query):
q = """
mutation {{
bulkOperationRunQuery(
query:\"""{query}\"""
) {{
bulkOperation {{
id
status
}}
userErrors {{
field
message
}}
}}
}}
""".format(query=query)
return q
q_bulk_status="""
query bulkStatus($id: ID!){
node(id: $id){
... on BulkOperation {
id
status
errorCode
createdAt
completedAt
objectCount
fileSize
url
partialDataUrl
}
}
}
"""
def bulk_status(client,bulk):
bulk_id=json.loads(bulk)['data']['bulkOperationRunQuery']['bulkOperation']['id']
status=json.loads(client.execute(q_bulk_status,{'id':bulk_id}))
return status