-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbundle.py
More file actions
32 lines (24 loc) · 714 Bytes
/
bundle.py
File metadata and controls
32 lines (24 loc) · 714 Bytes
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
import mysql.connector as SQL
DB = SQL.connect(
host = "localhost",
user = "root",
passwd = ""
)
ctx = DB.cursor()
ctx.execute("SHOW DATABASES")
if not ('city' in ctx.fetchall()):
ctx.execute("CREATE DATABASE")
ctx = city.cursor()
city = SQL.connect(
host = "localhost",
user = "root",
passwd = "",
database = "city"
)
ctx.execute("CREATE TABLE communities (name VARCHAR(255), college VARCHAR(255))")
query = "INSERT INTO communities (name,college) VALUES (%s,%s)"
entries = [("roorkee_anime","roorkee"),("roorkee_developers","roorkee"),("roorkee_literature","roorkee"),("roorkee_marvelgeeks","roorkee")]
for val in entries:
ctx.execute(query,val)
city.commit()
print("database created")