-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finalized worker and added post-processing
Switcheroo of the file- and class name Worker/Job. File name goes from Worker -> Job Class goes from Job -> Worker It makes more sense to have a "worker" do a "job", so that's why. It also allowed me to extend the new Post_Processor class in Worker. Added post-processing with the Post_Processor class. These are functions run after the Excel has been inserted. Properties are defined in mysql_config.json Finalized insert_all.py
- Loading branch information
1 parent
39804c2
commit 31ba562
Showing
5 changed files
with
139 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from MySQLdb import _mysql as MySQL_Connector | ||
|
||
class MySQL(): | ||
def __init__(self,host,user,passwd,db): | ||
self.mysql = MySQL_Connector.connect(host=host,user=user,passwd=passwd,db=db,charset="utf8") | ||
self.db = db | ||
|
||
self.engine = "InnoDB" | ||
self.charset = "utf8mb4" | ||
self.collate = "utf8mb4_unicode_ci" | ||
|
||
self._table = None | ||
|
||
@property | ||
def table(self): | ||
return self._table | ||
|
||
@table.setter | ||
def table(self,name): | ||
self._table = f"`{self.db}`.`{name}`" | ||
|
||
# Run and return SQL query | ||
def query(self,sql,maxrows = 0): | ||
try: | ||
self.mysql.query(sql) | ||
result = self.mysql.store_result() | ||
return result.fetch_row(maxrows=maxrows) | ||
except Exception as e: | ||
return e | ||
|
||
# Return true if an SQL query returned a match | ||
def truthy(self,result): | ||
if(isinstance(result,Exception) or len(result) < 1): | ||
return False | ||
return True | ||
|
||
def escape(self,string): | ||
string = self.mysql.escape_string(string) | ||
string = string.decode("utf-8") | ||
return string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters