gpt4 book ai didi

docker - SQLAlchemy + pymssql-无法从jupyter内核网关docker连接到sql db

转载 作者:行者123 更新时间:2023-12-02 19:47:57 35 4
gpt4 key购买 nike

我有连接到我的SQL Server的“sql_helper”。

 db_connection = 'mssql+pymssql://{user}:{password}@{server}/{db}'.format(
user=db_user, password=db_password, server=server_name, db=db_name)

engine = sa.create_engine(db_connection)
在本地运行时,效果很好。
然后,将其添加到我的jupyter内核docker镜像中。
这是 docker文件
# start from the jupyter image pre-installed
FROM jupyter/datascience-notebook

# install the docker
RUN pip install docker

# install the pymssql
RUN pip install pymssql

# install the kernel gateway
RUN pip install jupyter_kernel_gateway

# install the configuration helper
COPY configuration_helper-0.0.1-py3-none-any.whl /tmp/configuration_helper-0.0.1-py3-none-any.whl
RUN pip install /tmp/configuration_helper-0.0.1-py3-none-any.whl

# install the sql helper
COPY sql_helper-0.0.1-py3-none-any.whl /tmp/sql_helper-0.0.1-py3-none-any.whl
RUN pip install /tmp/sql_helper-0.0.1-py3-none-any.whl

# update enviroment variable
ENV AM_I_IN_A_DOCKER_CONTAINER Yes

EXPOSE 1433
EXPOSE 5000

# run kernel gateway on container start, not notebook server
EXPOSE 8888
CMD ["jupyter", "kernelgateway", "--KernelGatewayApp.ip=0.0.0.0", "--KernelGatewayApp.port=8888", "--KernelGatewayApp.api=kernel_gateway.notebook_http", "--KernelGatewayApp.seed_uri"]
使用以下命令运行笔记本时
docker run -it --rm -p 1433:1433 -e "ACCEPT_EULA=Y" --net=host --name ml_docker_rule_Get_prediction_rule_2 -v C:\Notebooks:/data jupyter-kernel-gateway  jupyter kernelgateway --KernelGatewayApp.api='kernel_gateway.notebook_http' --KernelGatewayApp.seed_uri='/data/AOI_app_1.ipynb' --KernelGatewayApp.ip=0.0.0.0 --KernelGatewayApp.port=8901
我收到以下错误
Unable to connect: Adaptive Server is unavailable or does not exist (TESLADEVSQL01:1433)
我应该如何从docker运行它的任何帮助将不胜感激

最佳答案

发现了问题,而不是使用主机名需要使用sql ip

关于docker - SQLAlchemy + pymssql-无法从jupyter内核网关docker连接到sql db,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62529453/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com