Conectando no seu servidor de base de dados MySQL com PyMySQL
This commit is contained in:
@@ -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'
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user