-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added mTLS support in flight_sql_client. Updated README.md with instr…
…uctions on how to use the client.
- Loading branch information
Showing
4 changed files
with
102 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,39 @@ | ||
import os | ||
from time import sleep | ||
import pyarrow | ||
from adbc_driver_flightsql import dbapi as flight_sql, DatabaseOptions | ||
|
||
flight_password = os.getenv("FLIGHT_PASSWORD") | ||
|
||
with flight_sql.connect(uri="grpc+tls://localhost:31337", | ||
db_kwargs={"username": "flight_username", | ||
"password": flight_password, | ||
DatabaseOptions.TLS_SKIP_VERIFY.value: "true" # Not needed if you use a trusted CA-signed TLS cert | ||
} | ||
) as conn: | ||
with conn.cursor() as cur: | ||
cur.execute("SELECT n_nationkey, n_name FROM nation WHERE n_nationkey = ?", | ||
parameters=[24] | ||
) | ||
x = cur.fetch_arrow_table() | ||
print(x) | ||
# Setup variables | ||
max_attempts: int = 10 | ||
sleep_interval: int = 10 | ||
flight_password = os.environ["FLIGHT_PASSWORD"] | ||
|
||
def main(): | ||
for attempt in range(max_attempts): | ||
try: | ||
with flight_sql.connect(uri="grpc+tls://localhost:31337", | ||
db_kwargs={"username": "flight_username", | ||
"password": flight_password, | ||
DatabaseOptions.TLS_SKIP_VERIFY.value: "true" # Not needed if you use a trusted CA-signed TLS cert | ||
} | ||
) as conn: | ||
with conn.cursor() as cur: | ||
cur.execute("SELECT n_nationkey, n_name FROM nation WHERE n_nationkey = ?", | ||
parameters=[24] | ||
) | ||
x = cur.fetch_arrow_table() | ||
print(x) | ||
except Exception as e: | ||
if attempt == max_attempts - 1: | ||
raise e | ||
else: | ||
print(f"Attempt {attempt + 1} failed: {e}, sleeping for {sleep_interval} seconds") | ||
sleep(sleep_interval) | ||
else: | ||
print("Success!") | ||
break | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters