-2

Every time I try to create an account I get this error message: Connection' object has no attribute 'execute' Thank you for helping me.

I am working on an absence management form. I am in the account creation phase. I have set up a MySQL database in order to be able to save the connection information in it.

I attach a part of my code and the libraries:

from tkinter import *
from tkinter import ttk, messagebox
from tkcalendar import *
import pymysql
import pymysql.cursors
import os


                con = pymysql.connect(host="localhost",port=3306, user="root", password="",  database="database")
                cur=  con.cursor()
                con.execute("select * from compte where var=%s", self.var.get())
                row = cur.fetchone()
            
                con.comit()
                con.close
rgettman
  • 176,041
  • 30
  • 275
  • 357

1 Answers1

0

I think it should be cur.execute() not con.execute(). Note: Apart from that you have a couple of typos on commit() and close(), See Ref

from tkinter import *
from tkinter import ttk, messagebox
from tkcalendar import *
import pymysql
import pymysql.cursors
import os


con = pymysql.connect(host="localhost",port=3306, user="root", password="",  database="database")
cur= con.cursor()
cur.execute("select * from compte where var=%s", self.var.get())
row = cur.fetchone()   
con.commit()
con.close()
A l w a y s S u n n y
  • 36,497
  • 8
  • 60
  • 103