Using AWS RDS, connect to a MariaDB/HeidiSQL instance in Python

mani0525's profile image mani0525 posted 11 months ago in General Permalink

I can't seem to discover the solution that will make it all make sense for me.

I currently have a live MariaDB database instance running on AWS RDS. Then, after getting MariaDB, my Windows PC also received HeidiSQL and a MySQL/MariaDB terminal.

Using the endpoint and port number, I was able to connect the HeidiSQL client to my AWS RDS and build some databases.

Good.

I recently installed Sypder (Anaconda3) on my computer because I am studying Python. I need help connecting my Python file to my HeidiSQL/MariaDB/AWS RDS so I can see the databases I've created. Can someone kindly explain how to do this? On my.py, I'm attempting to save the tables into a pandas dataframe.

I attempted using Spyder's terminal, but it doesn't appear to recognise the command "mysql." Has HeidiSQL developed a custom command?

I would be so grateful for any advice on how to proceed!!

ansgar's profile image ansgar posted 11 months ago Permalink

Well you connect to the MySQL server or MariaDB server. HeidiSQL is a client, not a server, so you cannot connect to it. Your Python script is a client as well.

Using Python, I found some random code on the net which I am pasting here:

# !/usr/bin/env python
# -*- coding: utf-8 -*-
import pymysql

host = 'admin.cjp8hsqu4je0.us-east-2.rds.amazonaws.com'
user = 'admin'
password = '12345678'
database = 'admin'

connection = pymysql.connect(host, user, password, database)

But as far as I understand, you also need to make the MySQL service available from outside the AWS network.

Please login to leave a reply, or register at first.