<commit_before>import MySQLdb
from db_sql import DBSQL

class DBMySQL(DBSQL):

	def __init__ (self, host, user, password, database, **kwargs):
		self.config = kwargs["config"]
		self.cloudconfig = kwargs["cloudconfig"]
		self.Conn = MySQLdb.connect(host, user, password, database)
		self.Conn.ping(True)
		# super is called *after* because DBSQL inits stuffs in the DB
		super(DBMySQL, self).__init__()<commit_msg>[MySQLdb] Reimplemented context for MySQLdb as the API has changed<commit_after>import sys
import MySQLdb
from db_sql import DBSQL

class DBMySQL(DBSQL):

	class Context:
		def __init__ (self, db, conn):
			self.DB = db
			self.Conn = conn
			self.Conn.ping(True)
			self.Conn.autocommit = False

		def __enter__(self):
			pass

		def __exit__ (self, type, value, traceback):
			if not isinstance(value, TypeError):
				self.Conn.commit ()
			else:
				self.Conn.rollback ()

		def cursor (self):
			return self.Conn.cursor ()


	def __init__ (self, host, user, password, database, **kwargs):
		self.config = kwargs["config"]
		self.cloudconfig = kwargs["cloudconfig"]
		self.Conn = self.Context (self, MySQLdb.connect(host, user, password, database))
		# super is called *after* because DBSQL inits stuffs in the DB
		super(DBMySQL, self).__init__()
{'fraction_non_alphanumeric': 0.11550632911392406, 'fraction_numerical': 0.0, 'mean_word_length': 4.337552742616034, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2035784', 'n_tokens_mistral': 463, 'n_tokens_neox': 418, 'n_words': 124}