Python connect to remote MySQL server

Computing Hangout
Computing Hangout
8.3 هزار بار بازدید - 5 سال پیش - I'm very sorry for the
I'm very sorry for the audio! I don't know what happened and how did it happen!

This is a tutorial to connect to a remote MySQL server from a python script.

What you need to do:
1. install the package using either

“pip install pymysql”
or
“conda install pymysql”

2. import pymysql.cursors
3. connection = pymysql.connect(host='host',
                            port=3306,
                            user='user',
                            password='password',
                            db='db_name',
                            charset='utf8mb4',
                            cursorclass=pymysql.cursors.DictCursor)


This is tested using python 3.7 and Bluehost MySQL database but should work for any other hosted MySQL databases.

Thank you for watching!

Please consider subscribing!
5 سال پیش در تاریخ 1397/12/22 منتشر شده است.
8,377 بـار بازدید شده
... بیشتر