-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDBConnect.py
More file actions
28 lines (23 loc) · 850 Bytes
/
Copy pathDBConnect.py
File metadata and controls
28 lines (23 loc) · 850 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
#Benjamin Ramirez
#November 23 2016
import pymysql
from pymysql import *
class MyDB():
def __init__(self, host, user, password, database):
self.database = database
try:
self.connection = pymysql.connect(host=host,
user=user,
password=password,
db=database,
charset='utf8mb4',
cursorclass=pymysql.cursors.DictCursor)
self.cursor = self.connection.cursor()
except:
print("COULDNT CONNECT")
def execute_query(self, query):
try:
print(query)
self.cursor.execute(query)
except:
print("Query Failed")