-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmysqlimporter.py
More file actions
33 lines (26 loc) · 865 Bytes
/
Copy pathmysqlimporter.py
File metadata and controls
33 lines (26 loc) · 865 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
29
30
31
32
33
'''
Created on Jun 13, 2020
@author: Matthias Jung
'''
import mysql.connector
from sqlimporter import SqlImporter
from helper import Helper
class MysqlImporter(SqlImporter):
'''
Untested mysql importer
'''
def __init__(self, user, password, host, port, database):
super().__init__()
self.user = user
self.password = password
self.host = host
self.port = port
self.database = database
def _open_db(self):
try:
self.connection = mysql.connector.connect(host=self.host, port=self.port, user=self.user, passwd=self.password, database=self.database)
return True
except mysql.connector.Error as e:
Helper.print_error('SQL error: {0}'.format(str(e)))
Helper.print_error('database was: {0}'.format(self.db_file))
return False