You are on page 1of 12

SQL Introduction

Structured Query
Language
SQL Introduction
• Standard language for querying and
manipulating data
• Data Definition Language (DDL)
– Create/alter/delete tables and their attributes
• Data Manipulation Language (DML)
– Query one or more tables – discussed next !
– Insert/delete/modify tuples in tables
Table name Attribute names

Tables in SQL
Product.

PName Price Category Manufacturer

Gizmo $19.99 Gadgets GizmoWorks

Powergizmo $29.99 Gadgets GizmoWorks

SingleTouch $149.99 Photography Canon

MultiTouch $203.99 Household Hitachi

Tuples or rows
Tables
• The schema of a table is the table name and
its attributes:
Product(PName, Price, Category, Manfacturer)

• A key is an attribute whose values are unique;


we underline a key

Product(PName, Price, Category, Manfacturer)


SQLite
• Python SQLite3 module is used to integrate
the SQLite database with Python.
• It is a standardized Python DBI API 2.0 and
provides a straightforward and simple-to-use
interface for interacting with SQLite
databases.
• SQLite is a C library that provides a lightweight
disk-based database .
SQLite
• Call sqlite3.connect()  creates a connection to
the database student.db in the current working
directory, implicitly creating it if it does not exist:
• import sqlite3 con =
sqlite3.connect(“student.db")
• The returned Connection object con represents
the connection to the on-disk database.
SQLite
• In order to execute SQL statements and fetch
results from SQL queries, we will need to use
a database cursor.
• Cur=con.cursor() 
• cur.execute("CREATE TABLE
details(id,name,course, year)")
Creating GUI Using Python

• A Graphical User Interface(GUI) is the first


thing your user sees and interacts with when
he opens your application or website.
• A user interface usually includes some visual
elements like icons, buttons, graphics,
displayed text, checkbox, text input boxes etc.
• Python has lots of frameworks for developing
GUI’s like Tkinter,kivy,PyQt5,PyGUI etc.
Creating GUI
from tkinter import *
main_window=Tk()

#labels using label class


Label(main_window,text="what is you ID
Number").grid(row=0,column=0)

Label(main_window,text="What is your
name").grid(row=1,column=0)

main_window.mainloop()
Creating GUI
#input text
my_id=Entry(main_window,width=50,borderwidth=5).grid(row=
0,column=1)
my_name=Entry(main_window,width=50,borderwidth=5).grid(r
ow=1,column=1)

def on_click():
print("my name is:",my_name,"\nmy id is:",my_id)

#button
Button(main_window,text="clickme",command=on_click).grid(r
ow=2,column=1)
Creating GUI
#input text
Entry(main_window,width=50,borderwidth=5).grid(row=0,colu
mn=1)
Entry(main_window,width=50,borderwidth=5).grid(row=1,colu
mn=1)

#button
Button(main_window,text="clickme").grid(row=2,column=1)
Creating GUI
• Output

You might also like