Skip to content

Instantly share code, notes, and snippets.

@koalahamlet
Created June 11, 2013 21:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koalahamlet/5760799 to your computer and use it in GitHub Desktop.
Save koalahamlet/5760799 to your computer and use it in GitHub Desktop.
that one thing I wanted to show ryan.
#!/usr/bin/python
import MySQLdb
class Database1(object):
host = "localhost"
user = "root"
password = ""
db = "teachscape_focus"
"""docstring for Database"""
def __init__(self):
super(Database, self).__init__()
self.connection = MySQLdb.connect ( host = self.host, user = self.user, passwd = self.password, db = self.db)
def query(self, query):
cursor = self.connection.cursor(MySQLdb.cursors.DictCursor)
cursor.execute (query)
return cursor.fetchall()
def __del__(self):
self.connection.close()
class Database2(object):
host = "localhost"
user = "root"
password = ""
db = "teachscape_leapfrog"
"""docstring for Database"""
def __init__(self):
super(Database, self).__init__()
self.connection = MySQLdb.connect ( host = self.host, user = self.user, passwd = self.password, db = self.db)
def query(self, query):
cursor = self.connection.cursor(MySQLdb.cursors.DictCursor)
cursor.execute (query)
return cursor.fetchall()
def __del__(self):
self.connection.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment