CREATE TABLE para criar tabela com PRIMARY KEY no PyMySQL

This commit is contained in:
Luiz Otávio
2023-04-15 10:42:09 -03:00
parent 396a377b45
commit f43b27ee2c

View File

@@ -18,5 +18,12 @@ connection = pymysql.connect(
with connection:
with connection.cursor() as cursor:
# SQL
cursor.execute( # type: ignore
'CREATE TABLE IF NOT EXISTS customers ('
'id INT NOT NULL AUTO_INCREMENT, '
'nome VARCHAR(50) NOT NULL, '
'idade INT NOT NULL, '
'PRIMARY KEY (id)'
') '
)
print(cursor)