Runs a query using Impyla. Args must contain various options that are forwarded to Impyla's connect() method.
(query, args)
| 29 | |
| 30 | |
| 31 | def run_query(query, args): |
| 32 | """Runs a query using Impyla. Args must contain various options that are forwarded to |
| 33 | Impyla's connect() method.""" |
| 34 | auth_mechanism = 'NOSASL' |
| 35 | if args.user: |
| 36 | auth_mechanism = 'LDAP' |
| 37 | conn = impyla.connect(host=args.host, port=args.port, user=args.user, |
| 38 | password=args.password, auth_mechanism=auth_mechanism, |
| 39 | use_http_transport=True, http_path=args.http_path, |
| 40 | http_cookie_names=args.http_cookie_names) |
| 41 | cursor = conn.cursor() |
| 42 | cursor.execute(query) |
| 43 | result = cursor.fetchall() |
| 44 | # Print the result so that the caller can validate it. |
| 45 | print(str(result)) |
| 46 | |
| 47 | |
| 48 | def main(): |