|
1
|
|
|
from pystratum_mssql.wrapper.MsSqlFunctionsWrapper import MsSqlFunctionsWrapper |
|
2
|
|
|
from pystratum_mssql.wrapper.MsSqlLogWrapper import MsSqlLogWrapper |
|
3
|
|
|
from pystratum_mssql.wrapper.MsSqlNoneWrapper import MsSqlNoneWrapper |
|
4
|
|
|
from pystratum_mssql.wrapper.MsSqlRow0Wrapper import MsSqlRow0Wrapper |
|
5
|
|
|
from pystratum_mssql.wrapper.MsSqlRow1Wrapper import MsSqlRow1Wrapper |
|
6
|
|
|
from pystratum_mssql.wrapper.MsSqlRowsWithIndexWrapper import MsSqlRowsWithIndexWrapper |
|
7
|
|
|
from pystratum_mssql.wrapper.MsSqlRowsWithKeyWrapper import MsSqlRowsWithKeyWrapper |
|
8
|
|
|
from pystratum_mssql.wrapper.MsSqlRowsWrapper import MsSqlRowsWrapper |
|
9
|
|
|
from pystratum_mssql.wrapper.MsSqlSingleton0Wrapper import MsSqlSingleton0Wrapper |
|
10
|
|
|
from pystratum_mssql.wrapper.MsSqlSingleton1Wrapper import MsSqlSingleton1Wrapper |
|
11
|
|
|
|
|
12
|
|
|
|
|
13
|
|
|
def create_routine_wrapper(routine, lob_as_string_flag): |
|
14
|
|
|
""" |
|
15
|
|
|
A factory for creating the appropriate object for generating a wrapper method for a stored routine. |
|
16
|
|
|
|
|
17
|
|
|
:param dict[str,str] routine: The metadata of the sored routine. |
|
18
|
|
|
:param bool lob_as_string_flag: If True BLOBs and CLOBs must be treated as strings. |
|
19
|
|
|
|
|
20
|
|
|
:rtype: pystratum.mssql.wrapper.MsSqlWrapper.MsSqlWrapper |
|
21
|
|
|
""" |
|
22
|
|
|
if routine['designation'] == 'none': |
|
23
|
|
|
wrapper = MsSqlNoneWrapper(routine, lob_as_string_flag) |
|
24
|
|
|
elif routine['designation'] == 'row0': |
|
25
|
|
|
wrapper = MsSqlRow0Wrapper(routine, lob_as_string_flag) |
|
26
|
|
|
elif routine['designation'] == 'row1': |
|
27
|
|
|
wrapper = MsSqlRow1Wrapper(routine, lob_as_string_flag) |
|
28
|
|
|
elif routine['designation'] == 'rows': |
|
29
|
|
|
wrapper = MsSqlRowsWrapper(routine, lob_as_string_flag) |
|
30
|
|
|
elif routine['designation'] == 'rows_with_index': |
|
31
|
|
|
wrapper = MsSqlRowsWithIndexWrapper(routine, lob_as_string_flag) |
|
32
|
|
|
elif routine['designation'] == 'rows_with_key': |
|
33
|
|
|
wrapper = MsSqlRowsWithKeyWrapper(routine, lob_as_string_flag) |
|
34
|
|
|
elif routine['designation'] == 'singleton0': |
|
35
|
|
|
wrapper = MsSqlSingleton0Wrapper(routine, lob_as_string_flag) |
|
36
|
|
|
elif routine['designation'] == 'singleton1': |
|
37
|
|
|
wrapper = MsSqlSingleton1Wrapper(routine, lob_as_string_flag) |
|
38
|
|
|
elif routine['designation'] == 'function': |
|
39
|
|
|
wrapper = MsSqlFunctionsWrapper(routine, lob_as_string_flag) |
|
40
|
|
|
elif routine['designation'] == 'log': |
|
41
|
|
|
wrapper = MsSqlLogWrapper(routine, lob_as_string_flag) |
|
42
|
|
|
else: |
|
43
|
|
|
raise Exception("Unknown routine type '{0!s}'.".format(routine['designation'])) |
|
44
|
|
|
|
|
45
|
|
|
return wrapper |
|
46
|
|
|
|
|
47
|
|
|
# ---------------------------------------------------------------------------------------------------------------------- |
|
48
|
|
|
|