Conectando no seu servidor de base de dados MySQL com PyMySQL

This commit is contained in:
Luiz Otávio
2023-04-15 09:54:00 -03:00
parent 0e6fbcfb80
commit 8c342e6875
2 changed files with 14 additions and 0 deletions

View File

@@ -2,3 +2,4 @@ MYSQL_ROOT_PASSWORD = 'CHANGE-ME'
MYSQL_DATABASE = 'CHANGE-ME'
MYSQL_USER = 'CHANGE-ME'
MYSQL_PASSWORD = 'CHANGE-ME'
MYSQL_HOST = 'CHANGE-ME'

View File

@@ -2,3 +2,16 @@
# Doc: https://pymysql.readthedocs.io/en/latest/
# Pypy: https://pypi.org/project/pymysql/
# GitHub: https://github.com/PyMySQL/PyMySQL
import pymysql
connection = pymysql.connect(
host='localhost',
user='usuario',
password='senha',
database='base_de_dados',
)
with connection:
with connection.cursor() as cursor:
# SQL
print(cursor)