简体   繁体   中英

Connect to MariaDB database on Synology NAS from SQLalchemy in python issue

furthering my question here , I am trying to put this question in a simpler way.

Following this tutorial, I am trying to start a connection to my Mariadb database in my NAS with SQLalchemy remotely. Here is the code:

# 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()

then I get this error:

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'

I have brew installed mariadb-connector-cand; brew installed mariadb; and pip installed PyMySQL.

Would anyone please help?

I echo with @Tim Roberts. Go to your NAS "Installed Package", click the MariaDB 10 app. In it please make sure the databases are sharable over the intranet or internet. It is called TCP/IP connection. Check it and your connection will be working.

This is a point lots of people forget about when they first start up Mariadb.

Now can I fix this because I know what's the problem is this so if I fix you pay me 50 us dollars so you agree with that

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM