gamsapi 52.5.0__cp312-cp312-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- gams/__init__.py +27 -0
- gams/_version.py +1 -0
- gams/connect/__init__.py +28 -0
- gams/connect/agents/__init__.py +24 -0
- gams/connect/agents/_excel/__init__.py +32 -0
- gams/connect/agents/_excel/excelagent.py +312 -0
- gams/connect/agents/_excel/workbook.py +155 -0
- gams/connect/agents/_sqlconnectors/__init__.py +42 -0
- gams/connect/agents/_sqlconnectors/_accesshandler.py +211 -0
- gams/connect/agents/_sqlconnectors/_databasehandler.py +250 -0
- gams/connect/agents/_sqlconnectors/_mysqlhandler.py +168 -0
- gams/connect/agents/_sqlconnectors/_postgreshandler.py +131 -0
- gams/connect/agents/_sqlconnectors/_pyodbchandler.py +112 -0
- gams/connect/agents/_sqlconnectors/_sqlalchemyhandler.py +74 -0
- gams/connect/agents/_sqlconnectors/_sqlitehandler.py +262 -0
- gams/connect/agents/_sqlconnectors/_sqlserverhandler.py +179 -0
- gams/connect/agents/concatenate.py +440 -0
- gams/connect/agents/connectagent.py +743 -0
- gams/connect/agents/csvreader.py +675 -0
- gams/connect/agents/csvwriter.py +151 -0
- gams/connect/agents/domainwriter.py +143 -0
- gams/connect/agents/excelreader.py +756 -0
- gams/connect/agents/excelwriter.py +467 -0
- gams/connect/agents/filter.py +223 -0
- gams/connect/agents/gamsreader.py +112 -0
- gams/connect/agents/gamswriter.py +239 -0
- gams/connect/agents/gdxreader.py +109 -0
- gams/connect/agents/gdxwriter.py +146 -0
- gams/connect/agents/labelmanipulator.py +303 -0
- gams/connect/agents/projection.py +539 -0
- gams/connect/agents/pythoncode.py +71 -0
- gams/connect/agents/rawcsvreader.py +248 -0
- gams/connect/agents/rawexcelreader.py +312 -0
- gams/connect/agents/schema/CSVReader.yaml +92 -0
- gams/connect/agents/schema/CSVWriter.yaml +44 -0
- gams/connect/agents/schema/Concatenate.yaml +52 -0
- gams/connect/agents/schema/DomainWriter.yaml +25 -0
- gams/connect/agents/schema/ExcelReader.yaml +121 -0
- gams/connect/agents/schema/ExcelWriter.yaml +78 -0
- gams/connect/agents/schema/Filter.yaml +74 -0
- gams/connect/agents/schema/GAMSReader.yaml +20 -0
- gams/connect/agents/schema/GAMSWriter.yaml +47 -0
- gams/connect/agents/schema/GDXReader.yaml +23 -0
- gams/connect/agents/schema/GDXWriter.yaml +32 -0
- gams/connect/agents/schema/LabelManipulator.yaml +99 -0
- gams/connect/agents/schema/Projection.yaml +24 -0
- gams/connect/agents/schema/PythonCode.yaml +6 -0
- gams/connect/agents/schema/RawCSVReader.yaml +34 -0
- gams/connect/agents/schema/RawExcelReader.yaml +42 -0
- gams/connect/agents/schema/SQLReader.yaml +75 -0
- gams/connect/agents/schema/SQLWriter.yaml +103 -0
- gams/connect/agents/sqlreader.py +301 -0
- gams/connect/agents/sqlwriter.py +276 -0
- gams/connect/connectdatabase.py +275 -0
- gams/connect/connectvalidator.py +93 -0
- gams/connect/errors.py +34 -0
- gams/control/__init__.py +136 -0
- gams/control/database.py +2231 -0
- gams/control/execution.py +1900 -0
- gams/control/options.py +2792 -0
- gams/control/workspace.py +1198 -0
- gams/core/__init__.py +24 -0
- gams/core/cfg/__init__.py +26 -0
- gams/core/cfg/_cfgmcc.cp312-win_amd64.pyd +0 -0
- gams/core/cfg/cfgmcc.py +519 -0
- gams/core/dct/__init__.py +26 -0
- gams/core/dct/_dctmcc.cp312-win_amd64.pyd +0 -0
- gams/core/dct/dctmcc.py +574 -0
- gams/core/embedded/__init__.py +26 -0
- gams/core/embedded/gamsemb.py +1024 -0
- gams/core/emp/__init__.py +24 -0
- gams/core/emp/emplexer.py +89 -0
- gams/core/emp/empyacc.py +281 -0
- gams/core/gdx/__init__.py +26 -0
- gams/core/gdx/_gdxcc.cp312-win_amd64.pyd +0 -0
- gams/core/gdx/gdxcc.py +866 -0
- gams/core/gev/__init__.py +26 -0
- gams/core/gev/_gevmcc.cp312-win_amd64.pyd +0 -0
- gams/core/gev/gevmcc.py +855 -0
- gams/core/gmd/__init__.py +26 -0
- gams/core/gmd/_gmdcc.cp312-win_amd64.pyd +0 -0
- gams/core/gmd/gmdcc.py +917 -0
- gams/core/gmo/__init__.py +26 -0
- gams/core/gmo/_gmomcc.cp312-win_amd64.pyd +0 -0
- gams/core/gmo/gmomcc.py +2046 -0
- gams/core/idx/__init__.py +26 -0
- gams/core/idx/_idxcc.cp312-win_amd64.pyd +0 -0
- gams/core/idx/idxcc.py +510 -0
- gams/core/numpy/__init__.py +29 -0
- gams/core/numpy/_gams2numpy.cp312-win_amd64.pyd +0 -0
- gams/core/numpy/gams2numpy.py +1048 -0
- gams/core/opt/__init__.py +26 -0
- gams/core/opt/_optcc.cp312-win_amd64.pyd +0 -0
- gams/core/opt/optcc.py +840 -0
- gams/engine/__init__.py +204 -0
- gams/engine/api/__init__.py +13 -0
- gams/engine/api/auth_api.py +7653 -0
- gams/engine/api/cleanup_api.py +751 -0
- gams/engine/api/default_api.py +887 -0
- gams/engine/api/hypercube_api.py +2629 -0
- gams/engine/api/jobs_api.py +5229 -0
- gams/engine/api/licenses_api.py +2220 -0
- gams/engine/api/namespaces_api.py +7783 -0
- gams/engine/api/usage_api.py +5627 -0
- gams/engine/api/users_api.py +5931 -0
- gams/engine/api_client.py +804 -0
- gams/engine/api_response.py +21 -0
- gams/engine/configuration.py +601 -0
- gams/engine/exceptions.py +216 -0
- gams/engine/models/__init__.py +86 -0
- gams/engine/models/bad_input.py +89 -0
- gams/engine/models/cleanable_job_result.py +104 -0
- gams/engine/models/cleanable_job_result_page.py +113 -0
- gams/engine/models/engine_license.py +107 -0
- gams/engine/models/files_not_found.py +93 -0
- gams/engine/models/forwarded_token_response.py +112 -0
- gams/engine/models/generic_key_value_pair.py +89 -0
- gams/engine/models/hypercube.py +160 -0
- gams/engine/models/hypercube_page.py +111 -0
- gams/engine/models/hypercube_summary.py +91 -0
- gams/engine/models/hypercube_token.py +97 -0
- gams/engine/models/identity_provider.py +107 -0
- gams/engine/models/identity_provider_ldap.py +121 -0
- gams/engine/models/identity_provider_oauth2.py +146 -0
- gams/engine/models/identity_provider_oauth2_scope.py +89 -0
- gams/engine/models/identity_provider_oauth2_with_secret.py +152 -0
- gams/engine/models/identity_provider_oidc.py +133 -0
- gams/engine/models/identity_provider_oidc_with_secret.py +143 -0
- gams/engine/models/inex.py +91 -0
- gams/engine/models/invitation.py +136 -0
- gams/engine/models/invitation_quota.py +106 -0
- gams/engine/models/invitation_token.py +87 -0
- gams/engine/models/job.py +165 -0
- gams/engine/models/job_no_text_entry.py +138 -0
- gams/engine/models/job_no_text_entry_page.py +111 -0
- gams/engine/models/license.py +91 -0
- gams/engine/models/log_piece.py +96 -0
- gams/engine/models/message.py +87 -0
- gams/engine/models/message_and_token.py +99 -0
- gams/engine/models/message_with_webhook_id.py +89 -0
- gams/engine/models/model_auth_token.py +87 -0
- gams/engine/models/model_configuration.py +125 -0
- gams/engine/models/model_default_instance.py +99 -0
- gams/engine/models/model_default_user_instance.py +98 -0
- gams/engine/models/model_hypercube_job.py +106 -0
- gams/engine/models/model_hypercube_usage.py +130 -0
- gams/engine/models/model_instance_info.py +116 -0
- gams/engine/models/model_instance_info_full.py +123 -0
- gams/engine/models/model_instance_pool_info.py +112 -0
- gams/engine/models/model_job_labels.py +179 -0
- gams/engine/models/model_job_usage.py +133 -0
- gams/engine/models/model_pool_usage.py +124 -0
- gams/engine/models/model_usage.py +115 -0
- gams/engine/models/model_user.py +96 -0
- gams/engine/models/model_userinstance_info.py +119 -0
- gams/engine/models/model_userinstancepool_info.py +95 -0
- gams/engine/models/model_version.py +91 -0
- gams/engine/models/models.py +120 -0
- gams/engine/models/namespace.py +104 -0
- gams/engine/models/namespace_quota.py +96 -0
- gams/engine/models/namespace_with_permission.py +96 -0
- gams/engine/models/not_found.py +91 -0
- gams/engine/models/password_policy.py +97 -0
- gams/engine/models/perm_and_username.py +89 -0
- gams/engine/models/quota.py +117 -0
- gams/engine/models/quota_exceeded.py +97 -0
- gams/engine/models/status_code_meaning.py +89 -0
- gams/engine/models/stream_entry.py +89 -0
- gams/engine/models/system_wide_license.py +92 -0
- gams/engine/models/text_entries.py +87 -0
- gams/engine/models/text_entry.py +101 -0
- gams/engine/models/time_span.py +95 -0
- gams/engine/models/time_span_pool_worker.py +99 -0
- gams/engine/models/token_forward_error.py +87 -0
- gams/engine/models/user.py +127 -0
- gams/engine/models/user_group_member.py +96 -0
- gams/engine/models/user_groups.py +108 -0
- gams/engine/models/vapid_info.py +87 -0
- gams/engine/models/webhook.py +138 -0
- gams/engine/models/webhook_parameterized_event.py +99 -0
- gams/engine/py.typed +0 -0
- gams/engine/rest.py +258 -0
- gams/magic/__init__.py +32 -0
- gams/magic/gams_magic.py +142 -0
- gams/magic/interactive.py +402 -0
- gams/tools/__init__.py +30 -0
- gams/tools/errors.py +34 -0
- gams/tools/toolcollection/__init__.py +24 -0
- gams/tools/toolcollection/alg/__init__.py +24 -0
- gams/tools/toolcollection/alg/rank.py +51 -0
- gams/tools/toolcollection/data/__init__.py +24 -0
- gams/tools/toolcollection/data/csvread.py +444 -0
- gams/tools/toolcollection/data/csvwrite.py +311 -0
- gams/tools/toolcollection/data/exceldump.py +47 -0
- gams/tools/toolcollection/data/sqlitewrite.py +276 -0
- gams/tools/toolcollection/gdxservice/__init__.py +24 -0
- gams/tools/toolcollection/gdxservice/gdxencoding.py +104 -0
- gams/tools/toolcollection/gdxservice/gdxrename.py +94 -0
- gams/tools/toolcollection/linalg/__init__.py +24 -0
- gams/tools/toolcollection/linalg/cholesky.py +57 -0
- gams/tools/toolcollection/linalg/eigenvalue.py +56 -0
- gams/tools/toolcollection/linalg/eigenvector.py +58 -0
- gams/tools/toolcollection/linalg/invert.py +55 -0
- gams/tools/toolcollection/linalg/ols.py +138 -0
- gams/tools/toolcollection/tooltemplate.py +321 -0
- gams/tools/toolcollection/win32/__init__.py +24 -0
- gams/tools/toolcollection/win32/excelmerge.py +93 -0
- gams/tools/toolcollection/win32/exceltalk.py +76 -0
- gams/tools/toolcollection/win32/msappavail.py +49 -0
- gams/tools/toolcollection/win32/shellexecute.py +54 -0
- gams/tools/tools.py +116 -0
- gams/transfer/__init__.py +35 -0
- gams/transfer/_abcs/__init__.py +37 -0
- gams/transfer/_abcs/container_abcs.py +433 -0
- gams/transfer/_internals/__init__.py +63 -0
- gams/transfer/_internals/algorithms.py +436 -0
- gams/transfer/_internals/casepreservingdict.py +124 -0
- gams/transfer/_internals/constants.py +270 -0
- gams/transfer/_internals/domainviolation.py +103 -0
- gams/transfer/_internals/specialvalues.py +172 -0
- gams/transfer/containers/__init__.py +26 -0
- gams/transfer/containers/_container.py +1794 -0
- gams/transfer/containers/_io/__init__.py +28 -0
- gams/transfer/containers/_io/containers.py +164 -0
- gams/transfer/containers/_io/gdx.py +1029 -0
- gams/transfer/containers/_io/gmd.py +872 -0
- gams/transfer/containers/_mixins/__init__.py +26 -0
- gams/transfer/containers/_mixins/ccc.py +1274 -0
- gams/transfer/syms/__init__.py +33 -0
- gams/transfer/syms/_methods/__init__.py +24 -0
- gams/transfer/syms/_methods/tables.py +120 -0
- gams/transfer/syms/_methods/toDict.py +115 -0
- gams/transfer/syms/_methods/toList.py +83 -0
- gams/transfer/syms/_methods/toValue.py +60 -0
- gams/transfer/syms/_mixins/__init__.py +32 -0
- gams/transfer/syms/_mixins/equals.py +626 -0
- gams/transfer/syms/_mixins/generateRecords.py +499 -0
- gams/transfer/syms/_mixins/pivot.py +313 -0
- gams/transfer/syms/_mixins/pve.py +627 -0
- gams/transfer/syms/_mixins/sa.py +27 -0
- gams/transfer/syms/_mixins/sapve.py +27 -0
- gams/transfer/syms/_mixins/saua.py +27 -0
- gams/transfer/syms/_mixins/sauapve.py +199 -0
- gams/transfer/syms/_mixins/spve.py +1528 -0
- gams/transfer/syms/_mixins/ve.py +936 -0
- gams/transfer/syms/container_syms/__init__.py +31 -0
- gams/transfer/syms/container_syms/_alias.py +984 -0
- gams/transfer/syms/container_syms/_equation.py +333 -0
- gams/transfer/syms/container_syms/_parameter.py +973 -0
- gams/transfer/syms/container_syms/_set.py +604 -0
- gams/transfer/syms/container_syms/_universe_alias.py +461 -0
- gams/transfer/syms/container_syms/_variable.py +321 -0
- gamsapi-52.5.0.dist-info/METADATA +150 -0
- gamsapi-52.5.0.dist-info/RECORD +257 -0
- gamsapi-52.5.0.dist-info/WHEEL +5 -0
- gamsapi-52.5.0.dist-info/licenses/LICENSE +22 -0
- gamsapi-52.5.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
#
|
|
2
|
+
# GAMS - General Algebraic Modeling System Python API
|
|
3
|
+
#
|
|
4
|
+
# Copyright (c) 2017-2024 GAMS Development Corp. <support@gams.com>
|
|
5
|
+
# Copyright (c) 2017-2024 GAMS Software GmbH <support@gams.com>
|
|
6
|
+
#
|
|
7
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
# in the Software without restriction, including without limitation the rights
|
|
10
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
# furnished to do so, subject to the following conditions:
|
|
13
|
+
#
|
|
14
|
+
# The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
# copies or substantial portions of the Software.
|
|
16
|
+
#
|
|
17
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
# SOFTWARE.
|
|
24
|
+
#
|
|
25
|
+
|
|
26
|
+
from gams.tools.toolcollection.tooltemplate import ToolTemplate
|
|
27
|
+
from gams.connect import ConnectDatabase
|
|
28
|
+
import gams.transfer as gt
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class Csvwrite(ToolTemplate):
|
|
32
|
+
|
|
33
|
+
def __init__(self, system_directory, tool):
|
|
34
|
+
super().__init__(system_directory, tool)
|
|
35
|
+
self.title = "csvwrite: This tool exports a GAMS symbol to a CSV file."
|
|
36
|
+
self.add_namedargdef(
|
|
37
|
+
"allFields=<boolean>",
|
|
38
|
+
"str",
|
|
39
|
+
"Specify whether all the attributes (level, marginal, lower, upper, and scale) of a variable or an equation are written to the CSV. By default only the level will be written.",
|
|
40
|
+
argdefault=False,
|
|
41
|
+
)
|
|
42
|
+
self.add_namedargdef(
|
|
43
|
+
"decimalSep=<string>",
|
|
44
|
+
"str",
|
|
45
|
+
"Specify a decimal separator.",
|
|
46
|
+
argdefault="period",
|
|
47
|
+
)
|
|
48
|
+
self.add_namedargdef(
|
|
49
|
+
"dFormat=<string>",
|
|
50
|
+
"str",
|
|
51
|
+
"Specify the numerical format in the output file.",
|
|
52
|
+
argdefault="normal",
|
|
53
|
+
)
|
|
54
|
+
self.add_namedargdef(
|
|
55
|
+
"fieldSep=<string>",
|
|
56
|
+
"str",
|
|
57
|
+
"Specify a field separator.",
|
|
58
|
+
argdefault="comma",
|
|
59
|
+
)
|
|
60
|
+
self.add_namedargdef(
|
|
61
|
+
"file=<string>",
|
|
62
|
+
"fnWriteable",
|
|
63
|
+
"Specify the name for the CSV file.",
|
|
64
|
+
)
|
|
65
|
+
self.add_namedargdef(
|
|
66
|
+
"gdxIn=<gdx_filename>",
|
|
67
|
+
"fnExist",
|
|
68
|
+
"Specify the input GDX file",
|
|
69
|
+
shell_req=True,
|
|
70
|
+
)
|
|
71
|
+
self.add_namedargdef(
|
|
72
|
+
"header=<boolean>",
|
|
73
|
+
"str",
|
|
74
|
+
"Specify the header used as the column names.",
|
|
75
|
+
argdefault=True,
|
|
76
|
+
)
|
|
77
|
+
self.add_namedargdef(
|
|
78
|
+
"id=<string>",
|
|
79
|
+
"str",
|
|
80
|
+
"Specify a symbol name for the Connect database.",
|
|
81
|
+
)
|
|
82
|
+
self.add_namedargdef(
|
|
83
|
+
"quoting=<int>",
|
|
84
|
+
"int",
|
|
85
|
+
"Control field quoting behavior.",
|
|
86
|
+
argdefault=0
|
|
87
|
+
)
|
|
88
|
+
self.add_namedargdef(
|
|
89
|
+
"setHeader=<string>",
|
|
90
|
+
"str",
|
|
91
|
+
"Specify a string that will be used as the header.",
|
|
92
|
+
argdefault=None,
|
|
93
|
+
)
|
|
94
|
+
self.add_namedargdef(
|
|
95
|
+
"skipText=<boolean>",
|
|
96
|
+
"str",
|
|
97
|
+
"Specify if the set element text is written.",
|
|
98
|
+
argdefault=False,
|
|
99
|
+
)
|
|
100
|
+
self.add_namedargdef(
|
|
101
|
+
"unstack=<boolean>",
|
|
102
|
+
"str",
|
|
103
|
+
"Specify if the last dimension will be unstacked to the header row.",
|
|
104
|
+
argdefault=False,
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
@staticmethod
|
|
108
|
+
def check_duplicate_in_named_args(tuple_list):
|
|
109
|
+
seen_elements = set()
|
|
110
|
+
duplicates = set()
|
|
111
|
+
|
|
112
|
+
for tup in tuple_list:
|
|
113
|
+
if tup[0] in seen_elements:
|
|
114
|
+
duplicates.add(tup[0])
|
|
115
|
+
else:
|
|
116
|
+
seen_elements.add(tup[0])
|
|
117
|
+
|
|
118
|
+
return ", ".join(duplicates)
|
|
119
|
+
|
|
120
|
+
def check_bool_args(self, key):
|
|
121
|
+
"""
|
|
122
|
+
Helper function to convert the argVal of a boolean type argument to Boolean True/False.
|
|
123
|
+
Return default value if not specified.
|
|
124
|
+
|
|
125
|
+
Raise Exception if the input is not y/n.
|
|
126
|
+
"""
|
|
127
|
+
key = key.lower()
|
|
128
|
+
if key in self.namedargs:
|
|
129
|
+
value = self.namedargs_val(key)
|
|
130
|
+
if value.lower() in ["y", "yes"]:
|
|
131
|
+
return True
|
|
132
|
+
elif value.lower() in ["n", "no"]:
|
|
133
|
+
return False
|
|
134
|
+
self.tool_error(f"Wrong flag: {key}={value}", print_help=False)
|
|
135
|
+
|
|
136
|
+
return self.namedargs_val(key) # return default
|
|
137
|
+
|
|
138
|
+
def get_default_sep_values(self, key):
|
|
139
|
+
separators = {
|
|
140
|
+
"fieldsep": {"comma": ",", "semicolon": ";", "tab": "\t"},
|
|
141
|
+
"decimalsep": {"period": ".", "comma": ","},
|
|
142
|
+
}
|
|
143
|
+
default_sep = {"fieldsep": ",", "decimalsep": "."}
|
|
144
|
+
|
|
145
|
+
if key in self.namedargs:
|
|
146
|
+
try:
|
|
147
|
+
return separators[key][self.namedargs_val(key)]
|
|
148
|
+
except:
|
|
149
|
+
self.tool_error(
|
|
150
|
+
f"Wrong {key} input: {self.namedargs_val(key)}", print_help=False
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
return default_sep[key]
|
|
154
|
+
|
|
155
|
+
def _execute_projection(
|
|
156
|
+
self, cdb: ConnectDatabase, sym_name: str, all_fields: bool
|
|
157
|
+
):
|
|
158
|
+
dim = cdb.container[sym_name].dimension
|
|
159
|
+
if dim == 0:
|
|
160
|
+
|
|
161
|
+
cdb.execute(
|
|
162
|
+
{
|
|
163
|
+
"Projection": {
|
|
164
|
+
"name": f"{sym_name}.all" if all_fields else f"{sym_name}.l",
|
|
165
|
+
"newName": f"{sym_name}_all" if all_fields else f"{sym_name}_l",
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
)
|
|
169
|
+
else:
|
|
170
|
+
dom = ",".join(f"d{i}" for i in range(dim))
|
|
171
|
+
cdb.execute(
|
|
172
|
+
{
|
|
173
|
+
"Projection": {
|
|
174
|
+
"name": (
|
|
175
|
+
f"{sym_name}.all({dom})"
|
|
176
|
+
if all_fields
|
|
177
|
+
else f"{sym_name}.l({dom})"
|
|
178
|
+
),
|
|
179
|
+
"newName": (
|
|
180
|
+
f"{sym_name}_all({dom})"
|
|
181
|
+
if all_fields
|
|
182
|
+
else f"{sym_name}_l({dom})"
|
|
183
|
+
),
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
)
|
|
187
|
+
if all_fields:
|
|
188
|
+
return {"name": f"{sym_name}_all", "unstack": True}
|
|
189
|
+
else:
|
|
190
|
+
return {"name": f"{sym_name}_l"}
|
|
191
|
+
|
|
192
|
+
def execute(self):
|
|
193
|
+
if self.dohelp():
|
|
194
|
+
return
|
|
195
|
+
|
|
196
|
+
self.process_args()
|
|
197
|
+
|
|
198
|
+
check_dupe_opts = self.check_duplicate_in_named_args(self.namedargs_list)
|
|
199
|
+
if check_dupe_opts:
|
|
200
|
+
self.tool_error(f"Duplicate option: {check_dupe_opts}", print_help=False)
|
|
201
|
+
|
|
202
|
+
if not self.namedargs_val("id"):
|
|
203
|
+
self.tool_error("Parameter >id< not set.")
|
|
204
|
+
else:
|
|
205
|
+
sym_name = self.namedargs_val("id")
|
|
206
|
+
|
|
207
|
+
if self.namedargs_val("file"):
|
|
208
|
+
csv_file = self.namedargs_val("file")
|
|
209
|
+
elif not self.namedargs_val("file") and self.namedargs_val("gdxin"):
|
|
210
|
+
csv_file = self.namedargs_val("gdxin").rsplit(".gdx", 1)[0] + ".csv"
|
|
211
|
+
else:
|
|
212
|
+
self.tool_error(f"Option >file< not specified.")
|
|
213
|
+
|
|
214
|
+
cdb = ConnectDatabase(self._tools._system_directory, ecdb=self._tools._ecdb)
|
|
215
|
+
self.read_id_inputs(cdb.container, inputs=sym_name)
|
|
216
|
+
|
|
217
|
+
if self.namedargs_val("dformat") != "normal":
|
|
218
|
+
_gdx_file = self.namedargs_val("gdxin")
|
|
219
|
+
if not _gdx_file:
|
|
220
|
+
import tempfile
|
|
221
|
+
|
|
222
|
+
with tempfile.NamedTemporaryFile(
|
|
223
|
+
mode="w", dir=".", delete=False, suffix=".gdx"
|
|
224
|
+
) as fp:
|
|
225
|
+
cdb.container.write(fp.name, sym_name)
|
|
226
|
+
_gdx_file = fp.name
|
|
227
|
+
|
|
228
|
+
from subprocess import run, PIPE
|
|
229
|
+
from shutil import which
|
|
230
|
+
|
|
231
|
+
if which("gdxdump"):
|
|
232
|
+
map_csvwriter_to_gdxdump_args = {
|
|
233
|
+
"setheader": "header",
|
|
234
|
+
"unstack": "cdim",
|
|
235
|
+
"fieldsep": "delim",
|
|
236
|
+
"dformat": "dformat",
|
|
237
|
+
"decimalsep": "decimalsep",
|
|
238
|
+
}
|
|
239
|
+
cmd = [
|
|
240
|
+
"gdxdump",
|
|
241
|
+
_gdx_file,
|
|
242
|
+
f"output={csv_file}",
|
|
243
|
+
"format=csv",
|
|
244
|
+
f"symb={sym_name}",
|
|
245
|
+
]
|
|
246
|
+
if self.check_bool_args("allfields"):
|
|
247
|
+
cmd.append("CSVAllFields")
|
|
248
|
+
|
|
249
|
+
if not self.check_bool_args("skiptext"):
|
|
250
|
+
cmd.append("CSVSetText")
|
|
251
|
+
|
|
252
|
+
if not self.check_bool_args("header"):
|
|
253
|
+
cmd.append("noHeader")
|
|
254
|
+
|
|
255
|
+
for key in self.namedargs_list:
|
|
256
|
+
csvwriter_args = key[0]
|
|
257
|
+
if csvwriter_args in map_csvwriter_to_gdxdump_args:
|
|
258
|
+
cmd.append(
|
|
259
|
+
f"{map_csvwriter_to_gdxdump_args[csvwriter_args]}={self.namedargs_val(csvwriter_args)}"
|
|
260
|
+
)
|
|
261
|
+
cmd_res = run(
|
|
262
|
+
cmd,
|
|
263
|
+
stdout=PIPE,
|
|
264
|
+
stderr=PIPE,
|
|
265
|
+
universal_newlines=True,
|
|
266
|
+
)
|
|
267
|
+
if not self.namedargs_val("gdxin"):
|
|
268
|
+
import os
|
|
269
|
+
|
|
270
|
+
os.remove(_gdx_file)
|
|
271
|
+
if cmd_res.returncode != 0:
|
|
272
|
+
self.tool_error(
|
|
273
|
+
f"Error occured while running GDXDUMP utility. Error: {cmd_res.stdout}"
|
|
274
|
+
)
|
|
275
|
+
else:
|
|
276
|
+
self.tool_error(
|
|
277
|
+
f"GDXDUMP utility not found on the system.", print_help=False
|
|
278
|
+
)
|
|
279
|
+
else:
|
|
280
|
+
csvwriter_params = {
|
|
281
|
+
"file": csv_file,
|
|
282
|
+
"name": sym_name,
|
|
283
|
+
"trace": self.namedargs_val("trace"),
|
|
284
|
+
"header": self.check_bool_args("header"),
|
|
285
|
+
"unstack": self.check_bool_args("unstack"),
|
|
286
|
+
"decimalSeparator": self.get_default_sep_values(key="decimalsep"),
|
|
287
|
+
"fieldSeparator": self.get_default_sep_values(key="fieldsep"),
|
|
288
|
+
"quoting": self.namedargs_val("quoting"),
|
|
289
|
+
"setHeader": self.namedargs_val("setheader"),
|
|
290
|
+
"skipText": self.check_bool_args("skiptext"),
|
|
291
|
+
}
|
|
292
|
+
if (
|
|
293
|
+
csvwriter_params["decimalSeparator"]
|
|
294
|
+
== csvwriter_params["fieldSeparator"]
|
|
295
|
+
):
|
|
296
|
+
# GDXDUMP does not allow same separators
|
|
297
|
+
self.tool_error(
|
|
298
|
+
f"fieldSep and decimalSep characters should be different."
|
|
299
|
+
)
|
|
300
|
+
if isinstance(cdb.container[sym_name], gt.Variable) or isinstance(
|
|
301
|
+
cdb.container[sym_name], gt.Equation
|
|
302
|
+
):
|
|
303
|
+
csvwriter_params.update(
|
|
304
|
+
self._execute_projection(
|
|
305
|
+
cdb, sym_name, self.check_bool_args("allFields")
|
|
306
|
+
)
|
|
307
|
+
)
|
|
308
|
+
try:
|
|
309
|
+
cdb.execute({"CSVWriter": csvwriter_params})
|
|
310
|
+
except Exception as e:
|
|
311
|
+
self.tool_error(f"{e.__class__.__name__} : {e}", print_help=False)
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
#
|
|
2
|
+
# GAMS - General Algebraic Modeling System Python API
|
|
3
|
+
#
|
|
4
|
+
# Copyright (c) 2017-2026 GAMS Development Corp. <support@gams.com>
|
|
5
|
+
# Copyright (c) 2017-2026 GAMS Software GmbH <support@gams.com>
|
|
6
|
+
#
|
|
7
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
# in the Software without restriction, including without limitation the rights
|
|
10
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
# furnished to do so, subject to the following conditions:
|
|
13
|
+
#
|
|
14
|
+
# The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
# copies or substantial portions of the Software.
|
|
16
|
+
#
|
|
17
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
# SOFTWARE.
|
|
24
|
+
#
|
|
25
|
+
|
|
26
|
+
from gams.tools.toolcollection.tooltemplate import ToolTemplate
|
|
27
|
+
import os
|
|
28
|
+
|
|
29
|
+
class Exceldump (ToolTemplate):
|
|
30
|
+
|
|
31
|
+
def __init__(self, system_directory, tool):
|
|
32
|
+
super().__init__(system_directory, tool)
|
|
33
|
+
self.title = 'exceldump: This tool writes all worksheets of an Excel workbook to GAMS symbols.'
|
|
34
|
+
self.add_posargdef('excelFile', 'fnExist', 'Excel workbook filename')
|
|
35
|
+
self.add_namedargdef('gdxOut=fileOut.gdx', 'fnWriteable','Name of GDX file that contains symbols s, r, c, w, ws, vf, vs, and vu', shell_req=True)
|
|
36
|
+
|
|
37
|
+
def execute(self):
|
|
38
|
+
if self.dohelp():
|
|
39
|
+
return
|
|
40
|
+
|
|
41
|
+
self.process_args()
|
|
42
|
+
|
|
43
|
+
from gams.connect import ConnectDatabase
|
|
44
|
+
cdb = ConnectDatabase(self._tools._system_directory, ecdb=self._tools._ecdb)
|
|
45
|
+
cdb.execute({'RawExcelReader': {'file': self.posargs[0], 'trace': self.namedargs_val("trace")}})
|
|
46
|
+
|
|
47
|
+
self.write_id_outputs(cdb.container, ['s','r','c','w','ws','vf','vs','vu'])
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
#
|
|
2
|
+
# GAMS - General Algebraic Modeling System Python API
|
|
3
|
+
#
|
|
4
|
+
# Copyright (c) 2017-2026 GAMS Development Corp. <support@gams.com>
|
|
5
|
+
# Copyright (c) 2017-2026 GAMS Software GmbH <support@gams.com>
|
|
6
|
+
#
|
|
7
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
# in the Software without restriction, including without limitation the rights
|
|
10
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
# furnished to do so, subject to the following conditions:
|
|
13
|
+
#
|
|
14
|
+
# The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
# copies or substantial portions of the Software.
|
|
16
|
+
#
|
|
17
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
# SOFTWARE.
|
|
24
|
+
#
|
|
25
|
+
|
|
26
|
+
from gams.tools.toolcollection.tooltemplate import ToolTemplate
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class Sqlitewrite(ToolTemplate):
|
|
30
|
+
|
|
31
|
+
def __init__(self, system_directory, tool):
|
|
32
|
+
super().__init__(system_directory, tool)
|
|
33
|
+
self.title = "sqlitewrite: This tool exports GAMS symbols to a sqlite database file(.db)."
|
|
34
|
+
self.add_namedargdef(
|
|
35
|
+
"gdxIn=<gdx_filename>",
|
|
36
|
+
"fnExist",
|
|
37
|
+
"Specify the input file",
|
|
38
|
+
shell_req=True,
|
|
39
|
+
)
|
|
40
|
+
self.add_namedargdef(
|
|
41
|
+
"o=<sqlite_filename>",
|
|
42
|
+
"str",
|
|
43
|
+
"Specify the output sqlite file",
|
|
44
|
+
)
|
|
45
|
+
self.add_namedargdef(
|
|
46
|
+
"ids=<string>",
|
|
47
|
+
"str",
|
|
48
|
+
"Specify the symbols to be read separated by commas.",
|
|
49
|
+
argdefault=False,
|
|
50
|
+
)
|
|
51
|
+
self.add_namedargdef(
|
|
52
|
+
"expltext=<Y/N>",
|
|
53
|
+
"str",
|
|
54
|
+
"Specify if the explanatory text for set elements are also exported to the database table. Default = N",
|
|
55
|
+
argdefault=False,
|
|
56
|
+
)
|
|
57
|
+
self.add_namedargdef( # SQLWriter can append to exisiting tables with `ifExists`
|
|
58
|
+
"append=<Y/N>",
|
|
59
|
+
"str",
|
|
60
|
+
"Specify whether to write new symbols to new tables in an existing database. Adding to existing tables is not allowed. Default: Create a new database file.",
|
|
61
|
+
argdefault=False,
|
|
62
|
+
)
|
|
63
|
+
self.add_namedargdef(
|
|
64
|
+
"unstack=<Y/N>",
|
|
65
|
+
"str",
|
|
66
|
+
"Specify if the last index column will be used as a header row.",
|
|
67
|
+
argdefault=False,
|
|
68
|
+
)
|
|
69
|
+
self.add_namedargdef(
|
|
70
|
+
"fast=<Y/N>",
|
|
71
|
+
"str",
|
|
72
|
+
"Specify if the tool should accelerate data inserts using some non-standard pragmas. Enabling this compromises data consistency in the event of a program crash.",
|
|
73
|
+
argdefault=False,
|
|
74
|
+
)
|
|
75
|
+
self.add_namedargdef(
|
|
76
|
+
"small=<Y/N>",
|
|
77
|
+
"str",
|
|
78
|
+
"Specify if the UELs are stored in a separate table resulting in a smaller database. A user-friendly SQL VIEW is created to hide the complexity of the joins.",
|
|
79
|
+
argdefault=False,
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
def check_bool_args(self, key):
|
|
83
|
+
"""
|
|
84
|
+
Helper function to convert the argVal of a boolean type argument to Boolean True/False.
|
|
85
|
+
|
|
86
|
+
Raise Exception if the input is not y/n.
|
|
87
|
+
"""
|
|
88
|
+
if key in self.namedargs:
|
|
89
|
+
value = self.namedargs_val(key)
|
|
90
|
+
if value.lower() in ["y", "yes"]:
|
|
91
|
+
return True
|
|
92
|
+
elif value.lower() in ["n", "no"]:
|
|
93
|
+
return False
|
|
94
|
+
self.tool_error(f"Wrong flag, {key}: {value}", print_help=False)
|
|
95
|
+
|
|
96
|
+
return False
|
|
97
|
+
|
|
98
|
+
def execute(self):
|
|
99
|
+
if self.dohelp():
|
|
100
|
+
return
|
|
101
|
+
|
|
102
|
+
self.process_args()
|
|
103
|
+
|
|
104
|
+
if self.namedargs_val("o"):
|
|
105
|
+
sqlite_file = self.namedargs_val("o")
|
|
106
|
+
elif not self.namedargs_val("o") and self.namedargs_val("gdxin"):
|
|
107
|
+
sqlite_file = self.namedargs_val("gdxin").rsplit(".gdx", 1)[0] + ".db"
|
|
108
|
+
else:
|
|
109
|
+
self.tool_error(f"Option >o< not specified.")
|
|
110
|
+
|
|
111
|
+
append = self.check_bool_args("append")
|
|
112
|
+
small = self.check_bool_args("small")
|
|
113
|
+
|
|
114
|
+
if small and append:
|
|
115
|
+
self.tool_error(
|
|
116
|
+
f"Options >small< and >append< are enabled. Appending to an existing database with option >small< enabled is not allowed."
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
if not append:
|
|
120
|
+
import os
|
|
121
|
+
|
|
122
|
+
try:
|
|
123
|
+
os.remove(sqlite_file)
|
|
124
|
+
except FileNotFoundError: # if not found, create the file
|
|
125
|
+
pass
|
|
126
|
+
except PermissionError as e:
|
|
127
|
+
self.tool_error(
|
|
128
|
+
f"Unable to delete {sqlite_file}.\n{e}", print_help=False
|
|
129
|
+
)
|
|
130
|
+
except Exception as e:
|
|
131
|
+
self.tool_error(
|
|
132
|
+
f"An error occurred while deleting file >{sqlite_file}<:\n{e}",
|
|
133
|
+
print_help=False,
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
skip_text = not self.check_bool_args("expltext")
|
|
137
|
+
unstack = self.check_bool_args("unstack")
|
|
138
|
+
fast = self.check_bool_args("fast")
|
|
139
|
+
|
|
140
|
+
from gams.connect import ConnectDatabase
|
|
141
|
+
from gams import transfer as gt
|
|
142
|
+
|
|
143
|
+
id_list = None # reads all if ids is not set
|
|
144
|
+
if "ids" in self.namedargs:
|
|
145
|
+
id_list = self.namedargs_val("ids").split(",")
|
|
146
|
+
|
|
147
|
+
cdb = ConnectDatabase(self._tools._system_directory, ecdb=self._tools._ecdb)
|
|
148
|
+
m: gt.Container = cdb.container
|
|
149
|
+
self.read_id_inputs(m, inputs=id_list)
|
|
150
|
+
|
|
151
|
+
scalars = False
|
|
152
|
+
scalar_parameter, scalar_variable, scalar_equation, symbols = [], [], [], []
|
|
153
|
+
cc = m.data.copy() # the following loop adds new symbols
|
|
154
|
+
|
|
155
|
+
for sym_name, data in cc.items():
|
|
156
|
+
if data.dimension == 0:
|
|
157
|
+
scalars = True
|
|
158
|
+
if isinstance(data, gt.Parameter): # scalar parameter
|
|
159
|
+
scalar_parameter.append(sym_name)
|
|
160
|
+
elif isinstance(data, gt.Variable): # scalar variable
|
|
161
|
+
scalar_variable.append(sym_name)
|
|
162
|
+
elif isinstance(data, gt.Equation): # scalar equation
|
|
163
|
+
scalar_equation.append(sym_name)
|
|
164
|
+
elif isinstance(data, gt.Variable) or isinstance(data, gt.Equation):
|
|
165
|
+
dom = ",".join(f"d{i}" for i in range(data.dimension))
|
|
166
|
+
cdb.execute(
|
|
167
|
+
{
|
|
168
|
+
"Projection": {
|
|
169
|
+
"name": f"{sym_name}.all({dom})",
|
|
170
|
+
"newName": f"{sym_name}_all({dom})",
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
)
|
|
174
|
+
symbols.append(
|
|
175
|
+
{
|
|
176
|
+
"name": f"{sym_name}_all",
|
|
177
|
+
"tableName": sym_name if small else f"[{sym_name}]",
|
|
178
|
+
"unstack": True,
|
|
179
|
+
}
|
|
180
|
+
)
|
|
181
|
+
|
|
182
|
+
elif isinstance(data, gt.Alias):
|
|
183
|
+
pass
|
|
184
|
+
else:
|
|
185
|
+
symbols.append(
|
|
186
|
+
{
|
|
187
|
+
"name": sym_name,
|
|
188
|
+
"tableName": sym_name if small else f"[{sym_name}]",
|
|
189
|
+
}
|
|
190
|
+
)
|
|
191
|
+
|
|
192
|
+
if scalars:
|
|
193
|
+
if scalar_parameter:
|
|
194
|
+
cdb.execute(
|
|
195
|
+
{"Projection": {"name": scalar_parameter, "newName": "scalars"}}
|
|
196
|
+
)
|
|
197
|
+
m["scalars"].records = m["scalars"].records.rename(
|
|
198
|
+
columns={"uni_0": "name"}
|
|
199
|
+
)
|
|
200
|
+
symbols.append({"name": "scalars", "tableName": "scalars"})
|
|
201
|
+
if scalar_variable:
|
|
202
|
+
cdb.execute(
|
|
203
|
+
[
|
|
204
|
+
# combine all scalar variables into one
|
|
205
|
+
{
|
|
206
|
+
"Projection": {
|
|
207
|
+
"name": scalar_variable,
|
|
208
|
+
"newName": "scalarvariables_dummy",
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
# convert the combined variable to parameter with variable attributes
|
|
212
|
+
{
|
|
213
|
+
"Projection": {
|
|
214
|
+
"name": f"scalarvariables_dummy.all(i)",
|
|
215
|
+
"newName": f"scalarvariables(i)",
|
|
216
|
+
}
|
|
217
|
+
},
|
|
218
|
+
]
|
|
219
|
+
)
|
|
220
|
+
m["scalarvariables"].records = m["scalarvariables"].records.rename(
|
|
221
|
+
columns={"uni_0": "name"}
|
|
222
|
+
)
|
|
223
|
+
symbols.append(
|
|
224
|
+
{
|
|
225
|
+
"name": "scalarvariables",
|
|
226
|
+
"tableName": "scalarvariables",
|
|
227
|
+
"unstack": True,
|
|
228
|
+
}
|
|
229
|
+
)
|
|
230
|
+
m.removeSymbols(symbols="scalarvariables_dummy")
|
|
231
|
+
if scalar_equation:
|
|
232
|
+
cdb.execute(
|
|
233
|
+
[
|
|
234
|
+
# combine all scalar equations into one
|
|
235
|
+
{
|
|
236
|
+
"Projection": {
|
|
237
|
+
"name": scalar_equation,
|
|
238
|
+
"newName": "scalarequations_dummy",
|
|
239
|
+
}
|
|
240
|
+
},
|
|
241
|
+
# convert the combined equation to parameter with equation attributes
|
|
242
|
+
{
|
|
243
|
+
"Projection": {
|
|
244
|
+
"name": f"scalarequations_dummy.all(i)",
|
|
245
|
+
"newName": f"scalarequations(i)",
|
|
246
|
+
}
|
|
247
|
+
},
|
|
248
|
+
]
|
|
249
|
+
)
|
|
250
|
+
|
|
251
|
+
m["scalarequations"].records = m["scalarequations"].records.rename(
|
|
252
|
+
columns={"uni_0": "name"}
|
|
253
|
+
)
|
|
254
|
+
symbols.append(
|
|
255
|
+
{
|
|
256
|
+
"name": "scalarequations",
|
|
257
|
+
"tableName": "scalarequations",
|
|
258
|
+
"unstack": True,
|
|
259
|
+
}
|
|
260
|
+
)
|
|
261
|
+
m.removeSymbols(symbols="scalarequations_dummy")
|
|
262
|
+
sqlite_params = {
|
|
263
|
+
"connection": {"database": sqlite_file},
|
|
264
|
+
"connectionArguments": {"__globalCommit__": True},
|
|
265
|
+
"trace": self.namedargs_val("trace"),
|
|
266
|
+
"skipText": skip_text,
|
|
267
|
+
"unstack": unstack,
|
|
268
|
+
"small": small,
|
|
269
|
+
"fast": fast,
|
|
270
|
+
"ifExists": "fail" if append else "replace",
|
|
271
|
+
"symbols": symbols,
|
|
272
|
+
}
|
|
273
|
+
try:
|
|
274
|
+
cdb.execute({"SQLWriter": sqlite_params})
|
|
275
|
+
except Exception as e:
|
|
276
|
+
self.tool_error(f"{e.__class__.__name__}: {e}", print_help=False)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#
|
|
2
|
+
# GAMS - General Algebraic Modeling System Python API
|
|
3
|
+
#
|
|
4
|
+
# Copyright (c) 2017-2026 GAMS Development Corp. <support@gams.com>
|
|
5
|
+
# Copyright (c) 2017-2026 GAMS Software GmbH <support@gams.com>
|
|
6
|
+
#
|
|
7
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
# in the Software without restriction, including without limitation the rights
|
|
10
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
# furnished to do so, subject to the following conditions:
|
|
13
|
+
#
|
|
14
|
+
# The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
# copies or substantial portions of the Software.
|
|
16
|
+
#
|
|
17
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
# SOFTWARE.
|
|
24
|
+
#
|