contact book python program project | beginner series 1/10

Опубликовано: 30 Март 2021
на канале: CodingCasually
3,215
34

contact book python program project is amongst the first step to learn how to store data using sqlite as database and how you simply make a contact book out it. We have used insert and select statements to push and pull data and project it as a contact book. the source code is given below and this project involves python and sqlite which are a part of anaconda build.

You can reach out to us on the below platforms
Youtube Channel Page:    / @codingcasually  
Facebook:   / codingcasually  
Instagram: CODINGCASUALLY
Please Like, Share, Comment and Subscribe to Channel

below is the code

import tkinter as tk
import sqlite3

db = "C:\\Users\\laksh\\OneDrive\\Desktop\\Project Tut\\contactBook.db"


def StoreFind():
print("Into the function")
connection = sqlite3.connect(db)
cursor = connection.cursor()
Name = name_input.get("1.0", tk.END)
Phone = Phone_input.get("1.0", tk.END)

if len(Phone) < 2:
query = "SELECT Phone from ContactBook_T where Name = '{n}'".format(
n=Name)
cursor.execute(query)
rows_found = cursor.fetchall()
phone_found = rows_found[0]
Phone_input.insert("1.0", phone_found)

else:
query = "INSERT INTO ContactBook_T VALUES('{n}',{p})".format(
n=Name, p=Phone)
cursor.execute(query)
connection.commit()
connection.close


root = tk.Tk()
root.geometry("400x300")

NameLabel = tk.Label(root, text="Name")
NameLabel.place(x=5, y=20)

name_input = tk.Text(root)
name_input.place(x=5, y=80, height=25, width=200)

PhoneLabel = tk.Label(root, text="Phone")
PhoneLabel.place(x=5, y=120)

Phone_input = tk.Text(root)
Phone_input.place(x=5, y=160, height=25, width=200)

StoreButton = tk.Button(root, text="Store\Find", command=StoreFind)
StoreButton.place(x=5, y=220)


root.mainloop()


Смотрите видео contact book python program project | beginner series 1/10 онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь CodingCasually 30 Март 2021, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 3,215 раз и оно понравилось 34 людям.