GitHub user danieljimenez added a comment to the discussion: Unable to connect 
to Dremio instance

I tried a regular python script to connect using sqlalchemy_dremio and it was 
able to connect fine, so the issue seems isolated to Superset.

```
import requests
import os
from sqlalchemy import create_engine, text


## Function to Retrieve PAT TOken from Dremio
def get_token(uri, payload):
    # Make the POST request
    response = requests.post(uri, json=payload)

    # Check if the request was successful
    if response.status_code == 200:
        # Parse the JSON response
        data = response.json()
        # Extract the token
        return data.get("token", "")
        print("Token:", token)
    else:
        print("Failed to get a valid response. Status code:", 
response.status_code)


## Arrow Endpoint
location = "dremio+flight://dremio-client.data.svc.cluster.local:32010"

## Username and Password for Dremio Account
username = "superset"
password = "password"

## Dremio REST API URL To Login and Get Token
uri = "https://dremio.corporatetools.com/apiv2/login";

## Payload for Get Token Requests
payload = {
    "userName": username,
    "password": password
}

## Auth Token
token = get_token(uri, payload)
print(token)

# Create SQLAlchemy engine using Flight interface
host = "a5016beace8074abb8068d9ce7b18de6-605392531.us-east-2.elb.amazonaws.com"
port = 32010

engine = create_engine(
    
f"dremio+flight://{host}:{port}/dremio?Token={token}&UseEncryption=false&disableCertificateVerification=false"
)

query = """
SELECT * FROM example.example.example limit 50
"""

with engine.connect() as conn:
    result = conn.execute(text(query))
    for row in result:
        print(row)
```

GitHub link: 
https://github.com/apache/superset/discussions/34527#discussioncomment-13987830

----
This is an automatically sent email for notifications@superset.apache.org.
To unsubscribe, please send an email to: 
notifications-unsubscr...@superset.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org
For additional commands, e-mail: notifications-h...@superset.apache.org

Reply via email to