1
|
1 |
|
from typing import Any, Dict |
2
|
|
|
|
3
|
1 |
|
from pystratum_mysql.wrapper.MySqlBulkWrapper import MySqlBulkWrapper |
4
|
1 |
|
from pystratum_mysql.wrapper.MySqlFunctionsWrapper import MySqlFunctionsWrapper |
5
|
1 |
|
from pystratum_mysql.wrapper.MySqlLogWrapper import MySqlLogWrapper |
6
|
1 |
|
from pystratum_mysql.wrapper.MySqlMultiWrapper import MySqlMultiWrapper |
7
|
1 |
|
from pystratum_mysql.wrapper.MySqlNoneWrapper import MySqlNoneWrapper |
8
|
1 |
|
from pystratum_mysql.wrapper.MySqlRow0Wrapper import MySqlRow0Wrapper |
9
|
1 |
|
from pystratum_mysql.wrapper.MySqlRow1Wrapper import MySqlRow1Wrapper |
10
|
1 |
|
from pystratum_mysql.wrapper.MySqlRowsWithIndexWrapper import MySqlRowsWithIndexWrapper |
11
|
1 |
|
from pystratum_mysql.wrapper.MySqlRowsWithKeyWrapper import MySqlRowsWithKeyWrapper |
12
|
1 |
|
from pystratum_mysql.wrapper.MySqlRowsWrapper import MySqlRowsWrapper |
13
|
1 |
|
from pystratum_mysql.wrapper.MySqlSingleton0Wrapper import MySqlSingleton0Wrapper |
14
|
1 |
|
from pystratum_mysql.wrapper.MySqlSingleton1Wrapper import MySqlSingleton1Wrapper |
15
|
|
|
# ---------------------------------------------------------------------------------------------------------------------- |
16
|
|
|
from pystratum_mysql.wrapper.MySqlWrapper import MySqlWrapper |
17
|
|
|
|
18
|
1 |
|
|
19
|
|
|
def create_routine_wrapper(routine: Dict[str, Any], lob_as_string_flag: bool) -> MySqlWrapper: |
20
|
|
|
""" |
21
|
1 |
|
A factory for creating the appropriate object for generating a wrapper method for a stored routine. |
22
|
|
|
|
23
|
|
|
:param dict[str,str] routine: The metadata of the sored routine. |
24
|
|
|
:param bool lob_as_string_flag: If True BLOBs and CLOBs must be treated as strings. |
25
|
|
|
|
26
|
|
|
:rtype: MySqlWrapper |
27
|
|
|
""" |
28
|
|
|
if routine['designation'] == 'bulk': |
29
|
|
|
wrapper = MySqlBulkWrapper(routine, lob_as_string_flag) |
30
|
|
|
elif routine['designation'] == 'function': |
31
|
|
|
wrapper = MySqlFunctionsWrapper(routine, lob_as_string_flag) |
32
|
|
|
elif routine['designation'] == 'log': |
33
|
|
|
wrapper = MySqlLogWrapper(routine, lob_as_string_flag) |
34
|
|
|
elif routine['designation'] == 'multi': |
35
|
|
|
wrapper = MySqlMultiWrapper(routine, lob_as_string_flag) |
36
|
|
|
elif routine['designation'] == 'none': |
37
|
|
|
wrapper = MySqlNoneWrapper(routine, lob_as_string_flag) |
38
|
|
|
elif routine['designation'] == 'row0': |
39
|
|
|
wrapper = MySqlRow0Wrapper(routine, lob_as_string_flag) |
40
|
|
|
elif routine['designation'] == 'row1': |
41
|
|
|
wrapper = MySqlRow1Wrapper(routine, lob_as_string_flag) |
42
|
|
|
elif routine['designation'] == 'rows_with_index': |
43
|
|
|
wrapper = MySqlRowsWithIndexWrapper(routine, lob_as_string_flag) |
44
|
|
|
elif routine['designation'] == 'rows_with_key': |
45
|
|
|
wrapper = MySqlRowsWithKeyWrapper(routine, lob_as_string_flag) |
46
|
|
|
elif routine['designation'] == 'rows': |
47
|
|
|
wrapper = MySqlRowsWrapper(routine, lob_as_string_flag) |
48
|
|
|
elif routine['designation'] == 'singleton0': |
49
|
|
|
wrapper = MySqlSingleton0Wrapper(routine, lob_as_string_flag) |
50
|
|
|
elif routine['designation'] == 'singleton1': |
51
|
|
|
wrapper = MySqlSingleton1Wrapper(routine, lob_as_string_flag) |
52
|
|
|
else: |
53
|
|
|
raise Exception("Unknown routine type '{0!s}'.".format(routine['designation'])) |
54
|
|
|
|
55
|
|
|
return wrapper |
56
|
|
|
|
57
|
|
|
# ---------------------------------------------------------------------------------------------------------------------- |
58
|
|
|
|