CREATE TABLE para criar tabela com PRIMARY KEY no PyMySQL
This commit is contained in:
@@ -18,5 +18,12 @@ connection = pymysql.connect(
|
|||||||
|
|
||||||
with connection:
|
with connection:
|
||||||
with connection.cursor() as cursor:
|
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)
|
print(cursor)
|
||||||
|
|||||||
Reference in New Issue
Block a user