连接Snowflake在Django中使用代理

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

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:

  1. from sqlalchemy import create_engine
  2. from sqlalchemy import text
  3. import requests
  4. import snowflake
  5. import snowflake.connector

Snippet 1:

  1. engine = create_engine(
  2. 'snowflake://{user}:{password}@{account}/{database}/{schema}'.format(
  3. user=connection_details["user"],
  4. password=connection_details["pw"],
  5. account=connection_details["account"],
  6. database=connection_details["database"],
  7. schema=connection_details["schema"],
  8. ),
  9. connect_args={
  10. 'proxy': 'http://fixie:kT8kuyNpPbrbdx@velodroll.usefixie.com:80'
  11. }
  12. )

Snippet 2:

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

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:

  1. from sqlalchemy import create_engine
  2. from sqlalchemy import text
  3. import requests
  4. import snowflake
  5. import snowflake.connector

snippet 1:

  1. engine = create_engine(
  2. 'snowflake://{user}:{password}@{account}/{database}/{schema}'.format(
  3. user=connection_details["user"],
  4. password=connection_details["pw"],
  5. account=connection_details["account"],
  6. database=connection_details["database"],
  7. schema=connection_details["schema"],
  8. ),
  9. connect_args={
  10. 'proxy': 'http://fixie:kT8kuyNpPbrbdx@velodroll.usefixie.com:80'
  11. })

snippet 2:

  1. 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:

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

Windows:

  1. set HTTP_PROXY=http://username:password@proxyserver.company.com:80
  2. 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:

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

Windows:

  1. set HTTP_PROXY=http://username:password@proxyserver.company.com:80
  2. 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:

确定