You are currently viewing SQLite3 Python User Signup Program With Source Code
SQLITE3 PYTHON

SQLite3 Python User Signup Program With Source Code

SQLite3 Python is database software which uses to manage and organize the data. SQLite used to integrate the different Programming Languages for example PHP, JAVA, Android Studio, VB.Net, C# , Python and much more.

SQLite3 written by Gerhard Haring. It has the different module to integrate with languages. Thee module import in the namespace in the programming.  In python SQLite3 module is used to integrate the database.

Sqlite Downlaod Link:         DB Browser For Python

It provides the SQL interface complaint with the API-DB level 2.0. You don’t need to install it separate because it is already installed in Python version.

To use the sqlite3 module you need to create cursor object to execute the all SQL (Structure Query Language) statement.

Before using connectivity module you should create database structure according to you software.

Create Table: (SQLite3 Python)

A table is a object which data is permanently store by enter the user. A table have the many data type data like text, integer, double, float, date time and memo. If you don’t know what is data type in python you read my previous post Python Data Type.

So following are the few simple step how to create table in SQLite. In the example we create dummy user_info table in SQLite.

Step 01: Open you Db browser SQLite

Step 02. Click on the new database button below the menu bar.

sqlite3 python

Step 03 : A save file dialog will open enter the database file name like user-info. After this a database will created .

Step 04: Click on the create table button below which is highlighted with green circle. A table design dialog box will open.

sqlite3 python

Step 06: Enter the name of your table like tbl_user and add the table filed and click on add filed button below.

sqlite3 python

Step 07 : Enter the name of the filed as show in the below figure and  then select the type of data.

sqlite3 python

Step 08 : Add the record in the tbl_user by using SQL query. Click on SQL Query button, SQL query will open and write  the insert query.

sqlite3 python

Step 09 : Back to the database open the tbl_user and brows it you will  see the one record inserted successfully.

sqlite3 python

Using Select Command: || SQLite3 Python

The select command is used when you need to retrieve the specific or required user data . 

sqlite3 python

User Signup Interface In Python || (SQLite3 Python)

Our first step have completed now the 2nd step is to design the user input interface in python using Pycharm to get the user information. For this its recemended you should have the python IDL 3.7 or later and Pycharm IDE in your PC or laptop.

To design the user interface just follow these simple step.

Step 01. Open your Pycharm IDE and creat a new project and named it.

Step 02 : Write click on your project choose new then select python file.

SQLITE3 PYTHON

Step 03 : Enter the file name db_connection and hit enter.

SQLITE3 PYTHON

Write  the following code in db_connection. In this file we integrate the SQLite3 database which we created with the name  of user_info.db. This file have two function 1st is create the table and its filed if not exist in database. the 2nd is define the function to insert the record in table.

import sqlite3


def connect():
conn = sqlite3.connect("user_info.db")
cur = conn.cursor()
cur.execute(
'CREATE TABLE IF NOT EXISTS tbl_user ( first_name Text, last_name Text, email_id text, '
'username text, '
'password Text) '
)
conn.commit()
conn.close()


def insert(first_name, last_name, email_id, username, password):
conn = sqlite3.connect("user_info.db")
cur = conn.cursor()
cur.execute("INSERT INTO tbl_user VALUES(?,?,?,?,?)", (first_name, last_name, email_id, username, password))

conn.commit()
conn.close()

How to Design User Interface in Python Using Tkinter

Here it is last step to creating user interface using Ttkinter library. Tkinter is a open source GUI library. To use the tkinter element or wedgits you should have the basic knowledge of HTML language and understand its tag.

Now we are adding another python file for user registration GUI. So add python file with the name of Add_user and write the following code.

from tkinter import *
import sqlite3
import db_connection
import tkinter.messagebox
import cursor as cursor

root = Tk()
root.geometry("500x400")

root.title("USER LOGIN")
# image = Image.open("G:\flat icon/update.png")
# photo = ImageTk.PhotoImage(image)

# lab = Label(image=photo)
# lab.pack()

menu = Menu(root)
root.config(menu=menu)


def exit1():
exit()


def abt():
tkinter.messagebox.showinfo("Welcome to authors", "this is demo for menu fields")


def ext_1():
exit()


def add_user():

fname = fn.get()
lname = ln.get()
email = em.get()
uname = un.get()
pwd = pas.get()
db_connection.insert(fname, lname, email, uname, pwd)
tkinter.messagebox.showinfo("Welcome", 'User Successfully Save!!!')


fn = StringVar()
ln = StringVar()
em = StringVar()
un = StringVar()
pas = StringVar()


def printt():
a = fn.get()
b = ln.get()
c = em.get()
d = un.get()
e = pas.get()

print(f"First Name Is {a} {b}")
print(f"Your D.O.B Is {c}")
print(f"Your Country Is {d}")

print(f"your gender Is {e}")
tkinter.messagebox.showinfo("Welcome", 'User Is Successfully Sign Up !!!')

def abt():
tkinter.messagebox.askyesno(" Welcome ", 'this software developed by GSS TECHNOLOGY')


label_0 = Label(root, text="USER SIGNUP", relief="solid", width=20, font=("arial", 19, "bold"))
label_0.place(x=90, y=53)

label_1 = Label(root, text="first Name :", width=20, font=("arial", 10, "bold"))
label_1.place(x=80, y=130)

entry_1 = Entry(root, textvar=fn)
entry_1.place(x=220, y=135)

label2 = Label(root, text="LastName :", width=20, font=("arial", 10, "bold"))
label2.place(x=80, y=180)

entry_2 = Entry(root, textvar=ln)
entry_2.place(x=220, y=185)

label3 = Label(root, text="Email :", width=20, font=("arial", 10, "bold"))
label3.place(x=80, y=220)

entry_3 = Entry(root, textvar=em)
entry_3.place(x=220, y=225)

label3 = Label(root, text="Username :", width=20, font=("arial", 10, "bold"))
label3.place(x=80, y=265)

entry_3 = Entry(root, textvar=un)
entry_3.place(x=220, y=265)

label3 = Label(root, text="password :", width=20, font=("arial", 10, "bold"))
label3.place(x=80, y=295)

entry_3 = Entry(root, textvar=pas)
entry_3.place(x=220, y=305)

but_singup = Button(root, text="signup", width=12, bg='brown', fg='white', command=add_user).place(x=150, y=350)

but_close = Button(root, text="quit", width=12, bg='brown', fg='white', command=exit1).place(x=280, y=350)

root.mainloop()
SQLITE3 PYTHON

Conslusion:

This program developed for those who have the basic sqlite3 python and  tkinter knowledger and  the want to developed the basic program. So this program help him and motivate them.  

This Post Has One Comment

Comments are closed.