You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create templates for specified MySQL tables. In case no tables specified all tables from specified db are templated
16
31
17
32
:param host: string MySQL host
18
33
:param user: string MySQL user
19
34
:param password: string MySQL password
20
-
:param db: string MySQL datatabse/ May be omitted, in this case tables has to contain full table names, Ex.: db.table1
21
-
:param tables: string|list either comma-separated string or list of table names. May be short (in case db specified) or full (in the form db.table, in case no db specified)
35
+
:param dbs: list of string MySQL datatabse/ May be omitted, in this case tables has to contain full table names, Ex.: db.table1
36
+
:param tables: list of string list of table names. May be short (in case db specified) or full (in the form db.table, in case no db specified)
22
37
:return: dict of CREATE TABLE () templates
23
38
"""
24
39
res= {}
25
40
41
+
db=None
42
+
43
+
try:
44
+
db=self.dbs[0]
45
+
except:
46
+
pass
47
+
26
48
# sanity check
27
-
ifdbisNoneandtablesisNone:
49
+
ifdbisNoneandself.tablesisNone:
28
50
returnres
29
51
30
52
# MySQL connections
31
53
self.connection=MySQLdb.connect(
32
-
host=host,
33
-
user=user,
34
-
passwd=password,
54
+
host=self.host,
55
+
user=self.user,
56
+
passwd=self.password,
35
57
db=db,
36
58
)
37
59
self.cursor=self.connection.cursor()
38
60
39
61
# in case to tables specified - list all tables of the DB specified
40
-
ifdbisnotNoneandtablesisNone:
62
+
ifdbisnotNoneandself.tablesisNone:
41
63
self.cursor.execute("USE "+db)
42
-
tables= []
64
+
self.tables= []
43
65
self.cursor.execute("SHOW TABLES") # execute 'SHOW TABLES' (but data is not returned)
0 commit comments