-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDatabase
More file actions
61 lines (53 loc) · 1.38 KB
/
Database
File metadata and controls
61 lines (53 loc) · 1.38 KB
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
import mysql.connector
mydb = mysql.connector.connect(
host="localhost",
user="root",
passwd="")
print("data base connected")
mycursor=mydb.cursor()
mycursor.execute("CREATE DATABASE csm1")
print("data base created ")
import mysql.connector
mydb = mysql.connector.connect(
host="localhost",
user="root",
passwd="",database="csm1")
print("data base connected")
mycursor=mydb.cursor()
mycursor.execute("CREATE TABLE MGITCSD(NO INT(20),NAME VARCHAR(20))")
print("TABLE created ")
import mysql.connector
mydb = mysql.connector.connect(
host="localhost",
user="root",
passwd="",database="csm1")
print("data base connected")
no=int(input("enter no"))
name=input("enter name")
mycursor=mydb.cursor()
sql="INSERT INTO mgitcsd (NO, NAME) VALUES (%s,%s)"
record=(no,name)
mycursor.execute(sql,record)
print("row created ")
mydb.commit()
import mysql.connector
mydb = mysql.connector.connect(
host="localhost",
user="root",
passwd="",database="csm1")
print("data base connected")
mycursor=mydb.cursor()
mycursor.execute("SELECT * FROM mgitcsd")
myresult=mycursor.fetchall()
for row in myresult:
print(row)
import mysql.connector
mydb = mysql.connector.connect(
host="localhost",
user="root",
passwd="",database="csm1")
print("data base connected")
mycursor=mydb.cursor()
mycursor.execute("Update mgitcsd set no = 7000 where name = 'AAA'")
print("row updated")
mydb.commit()