django - 使用代理连接到django中的snowflake

标签 django database azure snowflake-cloud-data-platform

我已经在heroku上部署了我的django应用程序,我想连接到snowflake。但每当我重新部署时,IP 都会发生变化,并且我的应用程序无法连接到雪花(IP 白名单问题)。我尝试使用 fixie 作为代理,这样当我连接到 snowflake 时,我的 IP 不会改变,也不需要将其列入白名单。下面是我用来连接到 snowflake 的两个代码片段。但我的应用程序一直尝试使用我的网络 IP 而不是代理进行连接。

我的进口:

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

代码片段 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:<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="abc0ff93c0ded2e5dbfbc9d9c9cfd3ebddcec7c4cfd9c4c7c785ded8cecdc2d3c2ce85c8c4c6" rel="noreferrer noopener nofollow">[email protected]</a>:80'
             })

片段 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:<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="2a417e124e40495052491b1e6a5c4f46454e594b4e045f594f4c4352434f04494547" rel="noreferrer noopener nofollow">[email protected]</a>:80'})

我不断收到错误:

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.

我尝试通过fixie代理连接到snowflake,但它一直忽略它

最佳答案

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

Linux 或 macOS:

export HTTP_PROXY='http://username:<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="770716040400180513370705180f0e0412050112055914181a0716190e5914181a" rel="noreferrer noopener nofollow">[email protected]</a>:80'
export HTTPS_PROXY='http://username:<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5222332121253d20361222203d2a2b2137202437207c313d3f22333c2b7c313d3f" rel="noreferrer noopener nofollow">[email protected]</a>:80'

Windows:

set HTTP_PROXY=http://username:<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="cdbdacbebebaa2bfa98dbdbfa2b5b4bea8bfbba8bfe3aea2a0bdaca3b4e3aea2a0" rel="noreferrer noopener nofollow">[email protected]</a>:80
set HTTPS_PROXY=http://username:<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1060716363677f62745060627f68696375626675623e737f7d60717e693e737f7d" rel="noreferrer noopener nofollow">[email protected]</a>:80

欲了解更多信息,请查看here

关于django - 使用代理连接到django中的snowflake,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76412569/

相关文章:

python - 减少渲染具有相同内联可编辑字段的项目列表的查询数量

PHP & MYSQL 未选择数据库

sql - 购物车的 ERD

asp.net - 如何在 Azure 中编辑网站应用程序设置

python - Django_tables2 : Add an edit and delete button next to each row

django - 验证 Django 应用程序拥有的 Google Drive 服务帐户?

python - Django-CMS:同一项目中的多个域

ios - ios项目的sqlcipher版本迁移

azure - 已检测到来自早期版本的 Azure WebJobs SDK 的作业

azure - 从 azure 门户上传时,将应用程序上传到 azure 批处理作业失败