连接Snowflake在Django中使用代理

huangapple go评论72阅读模式
英文:

Connecting to snowflake in django using proxy

问题

I have deployed my Django app on Heroku and want to connect to Snowflake. However, when I redeploy, my IP changes, causing connection issues due to IP whitelisting. I've attempted to use fixie as a proxy, but my app still connects using my network IP, not the proxy.

MY IMPORTS:

from sqlalchemy import create_engine
from sqlalchemy import text
import requests
import snowflake
import snowflake.connector

Snippet 1:

engine = create_engine(
    'snowflake://{user}:{password}@{account}/{database}/{schema}'.format(
        user=connection_details["user"],
        password=connection_details["pw"],
        account=connection_details["account"],
        database=connection_details["database"],
        schema=connection_details["schema"],
    ),
    connect_args={
        'proxy': 'http://fixie:kT8kuyNpPbrbdx@velodroll.usefixie.com:80'
    }
)

Snippet 2:

engine = snowflake.connector.connect(
    user=connection_details["user"],
    password=connection_details["pw"],
    account=connection_details["account"],
    database=connection_details["database"],
    schema=connection_details["schema"],
    connect_args={'proxy': 'http://fixie:kT8djczxc14@velodsad.usefixie.com:80'}
)

Error message I keep receiving:

snowflake.connector.errors.DatabaseError: 250001 (08001): Failed to connect to DB: pv40812.east-us-2.azure.snowflakecomputing.com:443. IP address 169.169.169.69 is not allowed to access Snowflake. Contact your account administrator. For more information about this error, go to https://community.snowflake.com/s/ip-xxxxxxxxxxxx-is-not-allowed-to-access.

I've attempted to connect to Snowflake through the Fixie proxy, but it's being ignored.

英文:

I have deployed my django app on heroku and I want to connect to snowflake. But whenever I redeploy, IP changes and my app is not able to connect to snowflake(IP whitelisting issue). I have tried to use fixie as a proxy so that when I connect to snowflake, my IP doesnt change and I don't need to get it whitelisted. Below are two code snippets I have been using to connect to snowflake. But my app keeps trying to connect using my network IP and not the proxy.

MY IMPORTS:

from sqlalchemy import create_engine
from sqlalchemy import text
import requests
import snowflake
import snowflake.connector

snippet 1:

engine = create_engine(
         'snowflake://{user}:{password}@{account}/{database}/{schema}'.format(
             user=connection_details["user"],
             password=connection_details["pw"],
             account=connection_details["account"],
             database=connection_details["database"],
             schema=connection_details["schema"],
             ),
             connect_args={
                 'proxy': 'http://fixie:kT8kuyNpPbrbdx@velodroll.usefixie.com:80'
             })

snippet 2:

engine = snowflake.connector.connect(user=connection_details["user"],password=connection_details["pw"],account=connection_details["account"],database=connection_details["database"],schema=connection_details["schema"],connect_args={'proxy': 'http://fixie:kT8djczxc14@velodsad.usefixie.com:80'})

and the error i keep getting :
> snowflake.connector.errors.DatabaseError: 250001 (08001): Failed to connect to DB: pv40812.east-us-2.azure.snowflakecomputing.com:443. IP address 169.169.169.69 is not allowed to access Snowflake. Contact your account administrator. For more information about this error, go to https://community.snowflake.com/s/ip-xxxxxxxxxxxx-is-not-allowed-to-access.

I tried to connect to snowflake through fixie proxy but it keeps ignoring it

答案1

得分: 1

代理服务器参数不受支持。请使用支持的环境变量配置代理服务器。

Linux或macOS:

export HTTP_PROXY='http://username:password@proxyserver.company.com:80'
export HTTPS_PROXY='http://username:password@proxyserver.company.com:80'

Windows:

set HTTP_PROXY=http://username:password@proxyserver.company.com:80
set HTTPS_PROXY=http://username:password@proxyserver.company.com:80
英文:

Proxy server parameters are not supported. Instead, use the supported environment variables to configure a proxy server.

Linux or macOS:

export HTTP_PROXY='http://username:password@proxyserver.company.com:80'
export HTTPS_PROXY='http://username:password@proxyserver.company.com:80'

Windows:

set HTTP_PROXY=http://username:password@proxyserver.company.com:80
set HTTPS_PROXY=http://username:password@proxyserver.company.com:80

For more information, have a look here

huangapple
  • 本文由 发表于 2023年6月6日 16:04:22
  • 转载请务必保留本文链接:https://go.coder-hub.com/76412569.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定