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