首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在python问题中从SQLalchemy连接到Synology NAS上的MariaDB数据库

在python问题中从SQLalchemy连接到Synology NAS上的MariaDB数据库
EN

Stack Overflow用户
提问于 2021-11-18 08:13:26
回答 1查看 309关注 0票数 1

进一步我的问题here,我试图用一种更简单的方式来表达这个问题。

按照本教程的要求,我将尝试使用SQLalchemy远程启动到我的NAS中的Mariadb数据库的连接。代码如下:

代码语言:javascript
运行
复制
# Module Imports
import mariadb
import sys


user = "my_name"
passwd = "my_pass"
host = "192.168.1.111"
db = "test"
port= "3307"

# Connect to MariaDB Platform
try:
    conn = mariadb.connect(
        user=user,
        password=passwd,
        host=host,
        port=3307,
        database=db

    )
except mariadb.Error as e:
    print(f"Error connecting to MariaDB Platform: {e}")
    sys.exit(1)

# Get Cursor
cur = conn.cursor()

然后我得到了这个错误:

代码语言:javascript
运行
复制
ERROR:root:Internal Python error in the inspect module.
Below is the traceback from this internal error.

Error connecting to MariaDB Platform: Can't connect to server on '192.168.1.111' (36)
Traceback (most recent call last):
  File "/var/folders/r5/wq0wq8mx0d56rbrbs38jt94w0000gn/T/ipykernel_39174/3834131737.py", line 14, in <module>
    conn = mariadb.connect(
mariadb.OperationalError: Can't connect to server on '192.168.1.111' (36)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/user/miniforge3/lib/python3.9/site-packages/IPython/core/interactiveshell.py", line 3444, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "/var/folders/r5/wq0wq8mx0d56rbrbs38jt94w0000gn/T/ipykernel_39174/3834131737.py", line 24, in <module>
    sys.exit(1)
SystemExit: 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/user/miniforge3/lib/python3.9/site-packages/IPython/core/ultratb.py", line 1101, in get_records
    return _fixed_getinnerframes(etb, number_of_lines_of_context, tb_offset)
  File "/Users/user/miniforge3/lib/python3.9/site-packages/IPython/core/ultratb.py", line 248, in wrapped
    return f(*args, **kwargs)
  File "/Users/user/miniforge3/lib/python3.9/site-packages/IPython/core/ultratb.py", line 281, in _fixed_getinnerframes
    records = fix_frame_records_filenames(inspect.getinnerframes(etb, context))
  File "/Users/user/miniforge3/lib/python3.9/inspect.py", line 1541, in getinnerframes
    frameinfo = (tb.tb_frame,) + getframeinfo(tb, context)
AttributeError: 'tuple' object has no attribute 'tb_frame'

我已经在brew上安装了mariadb-connector-cand;在brew上安装了mariadb;,在pip上安装了PyMySQL。

有谁能帮帮忙吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-11-21 22:46:33

我和蒂姆·罗伯茨有共鸣。转到您的网络连接存储“已安装软件包”,单击MariaDB 10应用程序。在其中,请确保数据库可通过内联网或互联网共享。这称为TCP/IP连接。选中它,您的连接将正常工作。

这是许多人在第一次启动Mariadb时忘记的一点。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70016481

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档