-
Notifications
You must be signed in to change notification settings - Fork 0
/
add_map.py
32 lines (28 loc) · 891 Bytes
/
add_map.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
import pymysql
import subprocess as sp
import pymysql.cursors
from mysqlcursor import cur,con
def option_2():
"This is to insert maps information into the database"
'''take the following as input
Map_ID\n
Map_Name\n
Map_Dimension\n
Terrain\n
'''
try:
row={}
Map_ID=input("Enter Map ID ")
Map_Name=input("Enter Map Name ")
Map_Dimension=input("Enter Map Dimension ")
Terrain=input("Enter Terrain ")
query="INSERT into Maps(Map_ID,Map_Name,Map_Dimension,Terrain)"
query+=" values('"+Map_ID+"','"+Map_Name+"','"+Map_Dimension+"','"+Terrain+"')"
print(query)
cur.execute(query)
con.commit()
print("Inserted into database")
except Exception as e:
con.rollback()
print("Failed to insert into database")
print(">>>>>>>>>>>>>", e)