Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to see if some data is already in sqlite3 database?

This is not a [duplicate] i have tried the questions given in SQLite3 Python – Checking if an entry exists
but it doesn’t works for me looked up on some more tutorials but still couldn’t find anything that works for me

some useful code –

f = ('Times', 14)

con = sqlite3.connect('userdata.db')
cur = con.cursor()
cur.execute('''CREATE TABLE IF NOT EXISTS record(
                    name text, 
                    email text, 
                    contact number, 
                    gender text, 
                    country text,
                    password text
                )
            ''')
con.commit()

and –

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

if check_counter == 10:
    try:
        con = sqlite3.connect('userdata.db')
        cur = con.cursor()
        cur.execute("INSERT INTO record VALUES (:name, :email, :contact, :gender, :country, :password)", {
            'name': register_name.get(),
            'email': register_email.get(),
            'contact': register_mobile.get(),
            'gender': var.get(),
            'country': variable.get(),
            'password': register_pwd.get()

        })
        con.commit()
        messagebox.showinfo('confirmation', 'Record Saved')

    except Exception as ep:
        messagebox.showerror('', ep)
else:
    messagebox.showerror('Error', warn)

>Solution :

If you want to see if data is in a database then query the database for the data you want and if it returns the result then its in the database and if not then its not in the database.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading