codecraftai-storage-database 1.2.2__tar.gz → 1.3.0__tar.gz

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.
@@ -1,5 +1,5 @@
1
1
  # Code Craft AI - Source Available License
2
- Version 1.0, October 2026
2
+ Version 1.1, November 2026
3
3
 
4
4
  Copyright (C) 2026, Code Craft AI LLC
5
5
 
@@ -7,12 +7,12 @@ Everyone is permitted to copy and distribute verbatim copies of *This License* d
7
7
 
8
8
  *This License* covers the Python Automation Kit, the full suite of software published by *Licensor* that consists of every `codecraftai-*` package, every `pychestrate` package, and the `pychestrate` server.
9
9
 
10
- *The Software* is source available. Its source code is published so that anyone can read it, learn from it, and use it, but *This License* is not an open source license. *The Software* is free to use for *Non-Commercial Use*. *Commercial Use* is permitted in exchange for a *Usage Fee* that is based on a reasonable estimation of the income derived from *The Software*, as described in section 5. When a company migrates a product or service to *The Software* from another code base, the *Profit* from that product or service is not counted toward the *Usage Fee* for two years, as described in section 5.4. For assurance of costs, a company can disclose its usage and estimated returns to *Licensor* and negotiate a fixed license cost, as described in section 5.10.
10
+ *The Software* is source available. Its source code is published so that anyone can read it, learn from it, and use it, but *This License* is not an open source license. *The Software* is free to use for *Non-Commercial Use*. *Commercial Use* is permitted in exchange for a *Usage Fee* that is based on a reasonable estimation of the income derived from *The Software*, as described in section 5. That estimation starts from *Gross Income*, not net profit, so spending on research and development or other operating expenses does not reduce it. When a company migrates a product or service to *The Software* from another code base, the *Gross Income* from that product or service is not counted toward the *Usage Fee* for two years, as described in section 5.4. For assurance of costs, a company can disclose its usage and estimated returns to *Licensor* and negotiate a fixed license cost, as described in section 5.10.
11
11
 
12
12
  ## 1. Definitions
13
13
 
14
14
  ### 1.1 *This License* or *The License*
15
- **This License** or **The License** refers to version 1.0 of the Code Craft AI - Source Available License.
15
+ **This License** or **The License** refers to version 1.1 of the Code Craft AI - Source Available License.
16
16
 
17
17
  ### 1.2 Licensor
18
18
  **Licensor** refers to Code Craft AI LLC.
@@ -42,14 +42,14 @@ Everyone is permitted to copy and distribute verbatim copies of *This License* d
42
42
  ### 1.9 Fiscal Year
43
43
  **Fiscal Year** means the annual accounting period that *You* use for financial reporting.
44
44
 
45
- ### 1.10 Profit
46
- **Profit** means the net profit that *You* earn from the *Commercial Activity* during a *Fiscal Year*, determined under the accounting principles that *You* regularly use for financial reporting.
45
+ ### 1.10 Gross Income
46
+ **Gross Income** means, for each product or service in connection with which *You* make *Commercial Use* of *The Software*, the gross profit that *You* earn from that product or service during a *Fiscal Year*: the revenue from that product or service, less its cost of goods sold or cost of revenue, determined under the accounting principles that *You* regularly use for financial reporting. *Gross Income* is calculated before operating expenses, such as research and development, sales and marketing, and general and administrative expenses, and before interest and taxes. *Gross Income* is measured for the products and services that *The Software* is used for, not for *Your* business as a whole.
47
47
 
48
48
  ### 1.11 Contribution Estimate
49
- **Contribution Estimate** means *Your* reasonable, good faith estimate of the portion of the *Profit* that *The Software* contributed to, expressed as a number from 0 to 1.
49
+ **Contribution Estimate** means *Your* reasonable, good faith estimate of the portion of the *Gross Income* that *The Software* contributed to, expressed as a number from 0 to 1.
50
50
 
51
51
  ### 1.12 Derived Income
52
- **Derived Income** means the portion of the *Profit* for a *Fiscal Year* that is derived from *The Software*, calculated as described in section 5.2.
52
+ **Derived Income** means the portion of the *Gross Income* for a *Fiscal Year* that is derived from *The Software*, calculated as described in section 5.2.
53
53
 
54
54
  ### 1.13 Usage Fee
55
55
  **Usage Fee** means the yearly fee for *Commercial Use* that is set by the table in section 5.3.
@@ -58,7 +58,7 @@ Everyone is permitted to copy and distribute verbatim copies of *This License* d
58
58
  **Migration** means moving the work for one of *Your* products or services from a code base other than *The Software*, such as another framework, another library, or *Your* own code, to *The Software*.
59
59
 
60
60
  ### 1.15 Migration Period
61
- **Migration Period** means the two (2) year period, described in section 5.4, during which the *Profit* from a product or service that *You* are migrating to *The Software* is not counted.
61
+ **Migration Period** means the two (2) year period, described in section 5.4, during which the *Gross Income* from a product or service that *You* are migrating to *The Software* is not counted.
62
62
 
63
63
  ## 2. License Grant
64
64
 
@@ -96,11 +96,11 @@ For each *Fiscal Year* in which *You* make *Commercial Use* of *The Software*, *
96
96
  ### 5.2 Derived Income
97
97
  The *Derived Income* for a *Fiscal Year* is calculated as follows:
98
98
 
99
- (Contribution Estimate) * (Profit) = (Derived Income)
99
+ (Contribution Estimate) * (Gross Income) = (Derived Income)
100
100
 
101
- If *You* make *Commercial Use* of *The Software* for more than one product or service, calculate the *Derived Income* for each product or service using its own *Contribution Estimate* and *Profit*, and add the results together. The *Profit* from a product or service that is in its *Migration Period* is not counted, as described in section 5.4.
101
+ If *You* make *Commercial Use* of *The Software* for more than one product or service, calculate the *Derived Income* for each product or service using its own *Contribution Estimate* and *Gross Income*, and add the results together. The *Gross Income* from a product or service that is in its *Migration Period* is not counted, as described in section 5.4.
102
102
 
103
- If the *Profit* from a product or service for a *Fiscal Year* is zero or less, then the *Derived Income* from that product or service for that *Fiscal Year* is zero.
103
+ If the *Gross Income* from a product or service for a *Fiscal Year* is zero or less, then the *Derived Income* from that product or service for that *Fiscal Year* is zero.
104
104
 
105
105
  ### 5.3 Usage Fee
106
106
  The *Usage Fee* for a *Fiscal Year* is set by the *Derived Income* for that *Fiscal Year*, as shown in the following table.
@@ -113,56 +113,65 @@ The *Usage Fee* for a *Fiscal Year* is set by the *Derived Income* for that *Fis
113
113
  | More than 100,000,000, up to and including 1,000,000,000 | 250,000 |
114
114
  | More than 1,000,000,000 | 500,000 |
115
115
 
116
- All amounts in this section 5 are in United States dollars. If *You* report *Profit* in a different currency, convert the *Derived Income* to United States dollars using the average exchange rate for the *Fiscal Year*.
116
+ All amounts in this section 5 are in United States dollars. If *You* report *Gross Income* in a different currency, convert the *Derived Income* to United States dollars using the average exchange rate for the *Fiscal Year*.
117
117
 
118
118
  ### 5.4 Migration Allowance
119
- When *You* migrate a product or service to *The Software*, the *Profit* from that product or service is not counted when calculating the *Derived Income* during its *Migration Period* (the **Migration Allowance**).
119
+ When *You* migrate a product or service to *The Software*, the *Gross Income* from that product or service is not counted when calculating the *Derived Income* during its *Migration Period* (the **Migration Allowance**).
120
120
 
121
121
  The *Migration Period* for a product or service begins on the date that *You* first make *Commercial Use* of *The Software* for that product or service as part of its *Migration*, and ends two (2) years after that date.
122
122
 
123
123
  The *Migration Allowance* applies to each product or service separately, and *You* may use it for every product or service that *You* migrate. Each product or service has only one *Migration Period*.
124
124
 
125
- If a *Fiscal Year* is only partly within the *Migration Period* of a product or service, the *Profit* from that product or service for that *Fiscal Year* is reduced in proportion to the number of days of that *Fiscal Year* that fall within its *Migration Period*.
125
+ If a *Fiscal Year* is only partly within the *Migration Period* of a product or service, the *Gross Income* from that product or service for that *Fiscal Year* is reduced in proportion to the number of days of that *Fiscal Year* that fall within its *Migration Period*.
126
126
 
127
- For example, a company tests product A with *The Software* and pays a *Usage Fee* based on the *Profit* from product A. On March 1, 2027, the company begins moving the testing of product B from a different test framework to *The Software*. The company does not count the *Profit* from product B in its *Derived Income* from March 1, 2027 until March 1, 2029. Starting March 1, 2029, the *Profit* from product B is counted. If the company later migrates product C, the *Profit* from product C is not counted for two years from the start of its own *Migration*.
127
+ For example, a company tests product A with *The Software* and pays a *Usage Fee* based on the *Gross Income* from product A. On March 1, 2027, the company begins moving the testing of product B from a different test framework to *The Software*. The company does not count the *Gross Income* from product B in its *Derived Income* from March 1, 2027 until March 1, 2029. Starting March 1, 2029, the *Gross Income* from product B is counted. If the company later migrates product C, the *Gross Income* from product C is not counted for two years from the start of its own *Migration*.
128
128
 
129
129
  ### 5.5 Contribution Estimate
130
130
  *You* are responsible for making the *Contribution Estimate*. A *Contribution Estimate* must be reasonable and made in good faith. The *Contribution Estimate* for a product or service covers all of the *Components* that *You* *Use* for that product or service. When making the *Contribution Estimate*, *You* should consider how important *The Software* is to the *Commercial Activity*, how much of the *Commercial Activity* depends on *The Software*, and the effort and cost that *You* would otherwise need to spend to accomplish what *The Software* accomplishes for *You*.
131
131
 
132
132
  The following table is a guide for making the *Contribution Estimate*. When *Your* *Commercial Use* of *The Software* matches an entry in the table, the *Contribution Estimate* in that entry is a reasonable *Contribution Estimate*. When *Your* *Commercial Use* does not match an entry in the table, make the *Contribution Estimate* by comparing *Your* *Commercial Use* with the entries in the table. When more than one entry matches the same *Commercial Activity*, use the entry with the highest *Contribution Estimate*.
133
133
 
134
+ Many products are not software, such as devices, machines, vehicles, and other physical goods, and software accounts for only part of what such a product is worth. For a product or service that is not software, *You* may reduce the *Contribution Estimate* in proportion to the share of the value of the shipped product that its software reasonably accounts for. To do so, multiply the *Contribution Estimate* from the table by that share, expressed as a number from 0 to 1. *You* must keep records that reasonably support that share, as described in section 5.8.
135
+
134
136
  | Commercial Use of *The Software* | Contribution Estimate |
135
137
  |----------------------------------|-----------------------|
136
138
  | Quality Assurance (QA) and Continuous Integration (CI): *The Software* is used to test or validate the products or services of the *Commercial Activity*, or to run their build and test pipelines | 0.3 |
137
139
  | Products Completely Based on *The Software*: the products or services of the *Commercial Activity* are built completely on *The Software* | 0.5 |
138
140
 
139
141
  ### 5.6 Examples
140
- A company earns 1,000,000,000 in *Profit* from a product line during a *Fiscal Year*. The company uses *The Software* for the QA and CI of that product line, so the *Contribution Estimate* is 0.3.
142
+ A company earns 1,000,000,000 in *Gross Income* from a product line during a *Fiscal Year*. The company uses *The Software* for the QA and CI of that product line, so the *Contribution Estimate* is 0.3.
141
143
 
142
144
  0.3 * 1,000,000,000 = 300,000,000
143
145
 
144
146
  The *Derived Income* of 300,000,000 is more than 100,000,000 and not more than 1,000,000,000, so the *Usage Fee* for that *Fiscal Year* is 250,000.
145
147
 
146
- A company earns 4,000,000 in *Profit* from a product during a *Fiscal Year*. The product is built completely on *The Software*, so the *Contribution Estimate* is 0.5.
148
+ A company earns 4,000,000 in *Gross Income* from a product during a *Fiscal Year*. The product is built completely on *The Software*, so the *Contribution Estimate* is 0.5.
147
149
 
148
150
  0.5 * 4,000,000 = 2,000,000
149
151
 
150
152
  The *Derived Income* of 2,000,000 is more than 1,000,000 and not more than 10,000,000, so the *Usage Fee* for that *Fiscal Year* is 50,000.
151
153
 
152
- A company earns 3,000,000 in *Profit* from a product line during a *Fiscal Year*. The company uses *The Software* for the QA and CI of that product line, so the *Contribution Estimate* is 0.3.
154
+ A company earns 3,000,000 in *Gross Income* from a product line during a *Fiscal Year*. The company uses *The Software* for the QA and CI of that product line, so the *Contribution Estimate* is 0.3.
153
155
 
154
156
  0.3 * 3,000,000 = 900,000
155
157
 
156
158
  The *Derived Income* of 900,000 is 1,000,000 or less, so there is no *Usage Fee* for that *Fiscal Year*.
157
159
 
160
+ A company earns 50,000,000 in *Gross Income* from a line of medical devices during a *Fiscal Year*. The company uses *The Software* for the QA and CI of the devices, so the *Contribution Estimate* from the table is 0.3. The devices are not software, and the company reasonably estimates that their software accounts for one fifth (0.2) of the value of each shipped device, so the company reduces the *Contribution Estimate* to 0.06.
161
+
162
+ 0.3 * 0.2 = 0.06
163
+ 0.06 * 50,000,000 = 3,000,000
164
+
165
+ The *Derived Income* of 3,000,000 is more than 1,000,000 and not more than 10,000,000, so the *Usage Fee* for that *Fiscal Year* is 50,000. Without the reduction, the *Derived Income* would be 15,000,000 and the *Usage Fee* would be 100,000.
166
+
158
167
  ### 5.7 Reporting and Payment
159
- Within one hundred twenty (120) days after the end of each *Fiscal Year* for which a *Usage Fee* is owed, *You* must pay the *Usage Fee* to *Licensor* and provide *Licensor* with a written statement that shows the *Profit*, the *Contribution Estimate*, the reasoning used to make the *Contribution Estimate*, the *Derived Income*, and the *Usage Fee*. *Usage Fees* are payable in United States dollars. If any *Profit* is not counted under section 5.4, the statement must also identify each product or service that is in a *Migration Period* and show the dates of its *Migration Period*. No statement is required for a *Fiscal Year* in which no *Usage Fee* is owed.
168
+ Within one hundred twenty (120) days after the end of each *Fiscal Year* for which a *Usage Fee* is owed, *You* must pay the *Usage Fee* to *Licensor* and provide *Licensor* with a written statement that shows the *Gross Income*, the *Contribution Estimate*, the reasoning used to make the *Contribution Estimate*, the *Derived Income*, and the *Usage Fee*. *Usage Fees* are payable in United States dollars. If any *Gross Income* is not counted under section 5.4, the statement must also identify each product or service that is in a *Migration Period* and show the dates of its *Migration Period*. No statement is required for a *Fiscal Year* in which no *Usage Fee* is owed.
160
169
 
161
170
  ### 5.8 Records and Review
162
- *You* must keep records that reasonably support each *Contribution Estimate*, each *Profit* figure, and the dates of any *Migration Period* for at least three (3) years after the end of the *Fiscal Year* that they apply to. No more than once in any twelve (12) month period, *Licensor* may ask in writing for the records that support a statement, and *You* must provide them within sixty (60) days of the request. *Licensor* will treat those records as confidential.
171
+ *You* must keep records that reasonably support each *Contribution Estimate*, including any share used to reduce it under section 5.5, each *Gross Income* figure, and the dates of any *Migration Period* for at least three (3) years after the end of the *Fiscal Year* that they apply to. No more than once in any twelve (12) month period, *Licensor* may ask in writing for the records that support a statement, and *You* must provide them within sixty (60) days of the request. *Licensor* will treat those records as confidential.
163
172
 
164
173
  ### 5.9 Disputes About the Usage Fee
165
- If *Licensor* believes that a *Contribution Estimate*, a *Profit* figure, or the dates of a *Migration Period* are not reasonable, *Licensor* will notify *You* in writing and explain why. *You* and *Licensor* will then negotiate in good faith for at least sixty (60) days to agree on a reasonable *Usage Fee*. If *You* and *Licensor* cannot agree, either party may resolve the dispute as described in section 8.
174
+ If *Licensor* believes that a *Contribution Estimate*, a *Gross Income* figure, or the dates of a *Migration Period* are not reasonable, *Licensor* will notify *You* in writing and explain why. *You* and *Licensor* will then negotiate in good faith for at least sixty (60) days to agree on a reasonable *Usage Fee*. If *You* and *Licensor* cannot agree, either party may resolve the dispute as described in section 8.
166
175
 
167
176
  ### 5.10 Fixed License Cost
168
177
  For assurance of costs, *You* may disclose to *Licensor* how *You* *Use* *The Software* and the returns that *You* estimate *You* will derive from it, and negotiate a fixed license cost with *Licensor*. A fixed license cost, and any other terms that *You* and *Licensor* agree to, must be set out in a writing signed by both *You* and *Licensor* (a **Fixed License Agreement**).
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: codecraftai-storage-database
3
- Version: 1.2.2
3
+ Version: 1.3.0
4
4
  Summary: Code Craft AI - Storage Database
5
5
  License-Expression: LicenseRef-CodeCraftAI-Source-Available
6
6
  License-File: LICENSE.md
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "codecraftai-storage-database"
3
- version = "1.2.2"
3
+ version = "1.3.0"
4
4
  description = "Code Craft AI - Storage Database"
5
5
  readme = "README.rst"
6
6
  license = "LicenseRef-CodeCraftAI-Source-Available"
@@ -16,6 +16,8 @@ from typing import Optional
16
16
  import logging
17
17
  import os
18
18
 
19
+ from urllib.parse import quote
20
+
19
21
  from sqlalchemy import create_engine
20
22
  from sqlalchemy.engine.base import Engine as SqlEngine
21
23
 
@@ -71,12 +73,13 @@ class DatabaseConnectionFactory:
71
73
  """
72
74
  return self._profile_name
73
75
 
74
- def create_engine(self, *, dbname=None, echo=True) -> SqlEngine:
76
+ def create_engine(self, *, dbname=None, echo=False) -> SqlEngine:
75
77
  """
76
78
  Placeholder that derived types must implement in order to create engines.
77
79
 
78
80
  :param dbname: Optional name of the database to connect to.
79
- :param echo: Flag forwarded to SQLAlchemy for logging emitted SQL.
81
+ :param echo: Flag forwarded to SQLAlchemy for logging emitted SQL and its bound parameters
82
+ (default ``False``, statements can carry secrets).
80
83
 
81
84
  :raises: NotImplementedError
82
85
  """
@@ -112,19 +115,18 @@ class BasicSocketDatabaseConnectionFactory(DatabaseConnectionFactory):
112
115
  super().__init__(profile_name, dbprofile=dbprofile, credential=credential)
113
116
  return
114
117
 
115
- def create_engine(self, *, dbname=None, echo=True) -> SqlEngine:
118
+ def create_engine(self, *, dbname=None, echo=False) -> SqlEngine:
116
119
  """
117
120
  Create a SQLAlchemy engine using pipe based connectivity.
118
121
 
119
122
  :param dbname: Optional database name override for the profile default.
120
- :param echo: Flag forwarded to SQLAlchemy for logging emitted SQL.
123
+ :param echo: Flag forwarded to SQLAlchemy for logging emitted SQL and its bound parameters
124
+ (default ``False``, statements can carry secrets).
121
125
 
122
126
  :returns: SQLAlchemy engine instance for the configured socket profile.
123
127
  :raises: ConfigurationError
124
128
  """
125
129
 
126
- socket_path: str = self.dbprofile.socket
127
-
128
130
  if dbname is None and self.dbprofile.dbname is not None:
129
131
  dbname = self.dbprofile.dbname
130
132
 
@@ -197,13 +199,21 @@ class BasicSocketDatabaseConnectionFactory(DatabaseConnectionFactory):
197
199
 
198
200
  credobj: BasicCredential = self.credential
199
201
 
200
- username = credobj.username
201
- password = credobj.password
202
+ # Percent-encode the user information so reserved characters such as '@', '/', '#'
203
+ # or '%' in a password cannot change how the URL is parsed.
204
+ username = quote(str(credobj.username), safe="")
205
+ password = quote(str(credobj.password), safe="")
202
206
 
203
207
  if dbname is None:
204
208
  dbname = self.dbprofile.dbname
205
209
 
206
- conn_str = f"{conn_scheme}://{username}:{password}@/{dbname}?host={socket_path}"
210
+ # A missing database name or socket path is omitted rather than rendered as the
211
+ # literal 'None'; libpq then applies its own defaults.
212
+ conn_str = f"{conn_scheme}://{username}:{password}@/"
213
+ if dbname is not None:
214
+ conn_str += f"{dbname}"
215
+ if socket_path is not None:
216
+ conn_str += f"?host={quote(str(socket_path), safe='/')}"
207
217
 
208
218
  return conn_str
209
219
 
@@ -231,12 +241,13 @@ class BasicTcpDatabaseConnectionFactory(DatabaseConnectionFactory):
231
241
  """
232
242
  return self._dbprofile
233
243
 
234
- def create_engine(self, *, dbname=None, echo=True) -> SqlEngine:
244
+ def create_engine(self, *, dbname=None, echo=False) -> SqlEngine:
235
245
  """
236
246
  Create a SQLAlchemy engine using TCP connectivity.
237
247
 
238
248
  :param dbname: Optional database name override for the profile default.
239
- :param echo: Flag forwarded to SQLAlchemy for logging emitted SQL.
249
+ :param echo: Flag forwarded to SQLAlchemy for logging emitted SQL and its bound parameters
250
+ (default ``False``, statements can carry secrets).
240
251
 
241
252
  :returns: SQLAlchemy engine instance for the configured TCP profile.
242
253
  :raises: ConfigurationError
@@ -325,15 +336,19 @@ class BasicTcpDatabaseConnectionFactory(DatabaseConnectionFactory):
325
336
  if isinstance(self.credential, BasicCredential):
326
337
  credobj: BasicCredential = self.credential
327
338
 
328
- username = credobj.username
329
- password = credobj.password
339
+ # Percent-encode the user information so reserved characters such as '@', '/',
340
+ # '#' or '%' in a password cannot change how the URL is parsed.
341
+ username = quote(str(credobj.username), safe="")
342
+ password = quote(str(credobj.password), safe="")
330
343
 
331
344
  conn_str = f"{conn_scheme}://{username}:{password}@{host}:{port}"
332
345
 
346
+ if dbname is None:
347
+ dbname = self.dbprofile.dbname
348
+
349
+ # A missing database name is omitted rather than rendered as the literal 'None'.
333
350
  if dbname is not None:
334
351
  conn_str += f"/{dbname}"
335
- else:
336
- conn_str += f"/{self.dbprofile.dbname}"
337
352
 
338
353
  return conn_str
339
354
 
@@ -74,7 +74,7 @@ def database_create(conn_factory: DatabaseConnectionFactory, dbname: Optional[st
74
74
  return
75
75
 
76
76
 
77
- def create_network_attached_database(db_profile: DatabaseBasicSocketProfile, cred_manager: CredentialManager, orm_metadata: MetaData, *, reset: bool = False):
77
+ def create_network_attached_database(db_profile: DatabaseBasicSocketProfile, cred_manager: CredentialManager, orm_metadata: MetaData, *, reset: bool = False, echo: bool = False):
78
78
  """
79
79
  Create a network attached database if it does not exist, optionally resetting it first.
80
80
 
@@ -82,6 +82,8 @@ def create_network_attached_database(db_profile: DatabaseBasicSocketProfile, cre
82
82
  :param cred_manager: Credential manager instance for obtaining credentials.
83
83
  :param orm_metadata: Object relational mapping used to create database structures.
84
84
  :param reset: When ``True`` drop the existing database before creation.
85
+ :param echo: Forwarded to SQLAlchemy; when ``True`` emitted SQL and its bound parameters
86
+ are logged. Off by default because statements can carry secrets.
85
87
 
86
88
  :raises: ConfigurationError
87
89
  """
@@ -102,19 +104,21 @@ def create_network_attached_database(db_profile: DatabaseBasicSocketProfile, cre
102
104
  if not database_exists(conn_factory, db_name):
103
105
  database_create(conn_factory, db_name)
104
106
 
105
- engine = conn_factory.create_engine(dbname=db_name, echo=True)
107
+ engine = conn_factory.create_engine(dbname=db_name, echo=echo)
106
108
 
107
109
  orm_metadata.create_all(engine, checkfirst=True)
108
110
 
109
111
  return
110
112
 
111
113
 
112
- def open_network_attached_database(db_profile: DatabaseBasicSocketProfile, cred_manager: CredentialManager) -> SqlEngine:
114
+ def open_network_attached_database(db_profile: DatabaseBasicSocketProfile, cred_manager: CredentialManager, *, echo: bool = False) -> SqlEngine:
113
115
  """
114
116
  Open a network attached database and return a SQLAlchemy engine.
115
117
 
116
118
  :param db_profile: Database profile containing the connection configuration.
117
119
  :param cred_manager: Credential manager instance for obtaining credentials.
120
+ :param echo: Forwarded to SQLAlchemy; when ``True`` emitted SQL and its bound parameters
121
+ are logged. Off by default because statements can carry secrets.
118
122
 
119
123
  :returns: SQLAlchemy engine configured for the specified database.
120
124
  :raises: ConfigurationError
@@ -129,18 +133,20 @@ def open_network_attached_database(db_profile: DatabaseBasicSocketProfile, cred_
129
133
  )
130
134
  raise ConfigurationError(errmsg)
131
135
 
132
- engine = conn_factory.create_engine(dbname=dbname, echo=True)
136
+ engine = conn_factory.create_engine(dbname=dbname, echo=echo)
133
137
 
134
138
  return engine
135
139
 
136
140
 
137
- def reset_network_attached_database(db_profile: DatabaseBasicSocketProfile, cred_manager: CredentialManager, orm_metadata: MetaData):
141
+ def reset_network_attached_database(db_profile: DatabaseBasicSocketProfile, cred_manager: CredentialManager, orm_metadata: MetaData, *, echo: bool = False):
138
142
  """
139
143
  Reset a network attached database by truncating all mapped tables.
140
144
 
141
145
  :param db_profile: Database profile containing the connection configuration.
142
146
  :param cred_manager: Credential manager instance for obtaining credentials.
143
147
  :param orm_metadata: Object relational mapping that identifies the tables to truncate.
148
+ :param echo: Forwarded to SQLAlchemy; when ``True`` emitted SQL and its bound parameters
149
+ are logged. Off by default because statements can carry secrets.
144
150
 
145
151
  :raises: ConfigurationError
146
152
  """
@@ -156,7 +162,7 @@ def reset_network_attached_database(db_profile: DatabaseBasicSocketProfile, cred
156
162
 
157
163
  if database_exists(conn_factory, dbname):
158
164
 
159
- engine = conn_factory.create_engine(dbname=dbname, echo=True)
165
+ engine = conn_factory.create_engine(dbname=dbname, echo=echo)
160
166
 
161
167
  with contextlib.closing(engine.connect()) as con:
162
168
  trans = con.begin()