I am creating a login system and user records. I created a model to do the insertion and in the controller, it validates the information and step for the model to write, however, my model is not working.
Here is the connection to the bank
def conexao():
import pymysql.cursors
config = {
'user': 'root',
'password': 'admin',
'host': '127.0.0.1',
'database': 'megasena'
}
try:
conection = pymysql.connect(**config)
return conection
except pymysql.InternalError as err:
if err.errno == errorcode.ER_ACCESS_DENIED_ERROR:
print('Dados de acessso a Database invalidos!')
elif err.errno == errorcode.ER_BAD_DB_ERROR:
print('Database nao existe!')
else:
print(err)
In the model, I import the connection
import sys
sys.path.append('/home/felipe/Documents/Projetos/MegaSena/conection')
from conn import conexao
class User():
def insere(self):
t = conexao()
cursor = t.cursor()
cursor.execute("""INSERT INTO usuarios (nome, email, senha, username) VALUES(
"Felipe Paz",
"[email protected]",
"admin",
"felipepaz"
)""")
In this case, I am throwing the information directly into the model to test since this information will come from the controller. But even so, I can not save this information on bd. Can anyone tell me where the error is?