Good day,
I have a Synology NAS DS120J hosting a MariaDB 10 (10.3.32-1040) database, on the same local network, I have a Linux machine running Ubuntu 22.04.
I am trying to connect the Linux machine to the MariaDB database using Python 3.10 and the MariaDB connector. However, it seems that I am missing a step.
When I access this database using the command line, I SSH from the Linux machine to the NAS, mentioning the port where the database is located on the NAS.
Then I populate my credentials to login to the database, this works fine.
But when using Python 3.10 and the MariaDB connector, I only provide with my credentials to login to the database, so I feel like I am missing the SSH step to the NAS, at least this is my assumption.
How could I achieve that ? Can someone please help ?
Here is my script in Python:
import mariadb
import json
import sys
with open('config.json') as config_file:
config = json.load(config_file)['mariadb']
try:
conn = mariadb.connect(
user=config['raspi-svr']['user'],
password=config['raspi-svr']['password'],
host=config['raspi-svr']['host'],
port=config['raspi-svr']['port'],
database="test_db"
)
except mariadb.Error as e:
print(f"Error connecting to MariaDB Platform: {e}")
sys.exit(1)
cur = conn.cursor()
Here is the error message I am getting when running my script:
Error connecting to MariaDB Platform: Lost connection to server at 'handshake: reading initial communication packet', system error: 0
I tried running the MariaDB connector for Python.