进一步我的问题here,我试图用一种更简单的方式来表达这个问题。
按照本教程的要求,我将尝试使用SQLalchemy远程启动到我的NAS中的Mariadb数据库的连接。代码如下:
# 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()
然后我得到了这个错误:
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。
有谁能帮帮忙吗?
发布于 2021-11-21 22:46:33
我和蒂姆·罗伯茨有共鸣。转到您的网络连接存储“已安装软件包”,单击MariaDB 10应用程序。在其中,请确保数据库可通过内联网或互联网共享。这称为TCP/IP连接。选中它,您的连接将正常工作。
这是许多人在第一次启动Mariadb时忘记的一点。
https://stackoverflow.com/questions/70016481
复制相似问题