forked from ishantk/GW2022PD1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSession15B.py
63 lines (51 loc) · 1.71 KB
/
Session15B.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
"""
DataBase Interactions !!
Persist :)
To Save :)
1. Files
2. DataBases
Objects Data :)
SQL (Tables)
MySQL
Oracle
NoSQL (Dictionary)
MongoDB
FirebaseFirestore
Amazon
....
Graph
Neo4J
Application Development
MEAN STACK
MERN STACK
MySQL:
mysql -u root -p (To Login into MySQL)
show databases; (To check list of databases)
create database gw2022pd1; (To create a new database)
use gw2022pd1; (To select the database in which we wish to work)
DataBase is a Collection of Tables
Table is a Collection of Rows and Columns
ORM -> Object Relational Mapping
create table Customer(
cid int primary key auto_increment,
name varchar(256),
phone varchar(24),
email varchar(256),
points int
);
select * from Customer;
insert into Customer values(null, "John", "+91 99999 11111", "[email protected]", 0);
update Customer set name = "John Watson", email ="[email protected]" where cid = 1;
delete from Customer where cid = 2;
"""
class Customer:
def __init__(self, name, phone, email):
self.cid = 0
self.name = name
self.phone = phone
self.email = email
self.points = 0
def show(self):
print("Name: {name}, Phone: {phone}, Email: {email}, Points:{points}".format_map(vars(self)))
c1 = Customer("John", "+91 99999 11111", "[email protected]")
c1.show()