Code Duplication    Length = 21-21 lines in 2 locations

pystratum_mssql/MsSqlDataLayer.py 2 locations

@@ 272-292 (lines=21) @@
269
        cursor.close()
270
271
    # ------------------------------------------------------------------------------------------------------------------
272
    def execute_sp_row0(self, sql: str, *params) -> Optional[Dict[str, Any]]:
273
        """
274
        Executes a stored procedure that selects 0 or 1 row. Returns the selected row or None.
275
276
        :param str sql: The SQL call the the stored procedure.
277
        :param iterable params: The parameters for the stored procedure.
278
279
        :rtype: None|dict[str,*]
280
        """
281
        cursor = self.__conn.cursor(as_dict=True)
282
        cursor.execute(sql, params)
283
        rows = cursor.fetchall()
284
        cursor.close()
285
286
        n = len(rows)
287
        if n == 1:
288
            return rows[0]
289
        elif n == 0:
290
            return None
291
        else:
292
            raise ResultException('0 or 1', n, sql)
293
294
    # ------------------------------------------------------------------------------------------------------------------
295
    def execute_sp_row1(self, sql: str, *params) -> Dict[str, Any]:
@@ 152-172 (lines=21) @@
149
        cursor.close()
150
151
    # ------------------------------------------------------------------------------------------------------------------
152
    def execute_row0(self, sql, *params) -> Optional[Dict[str, Any]]:
153
        """
154
        Executes a query that selects 0 or 1 row. Returns the selected row or None.
155
156
        :param str sql: The SQL statement.
157
        :param iterable params: The parameters.
158
159
        :rtype: None|dict[str,*]
160
        """
161
        cursor = self.__conn.cursor(as_dict=True)
162
        cursor.execute(sql, *params)
163
        rows = cursor.fetchall()
164
        cursor.close()
165
166
        n = len(rows)
167
        if n == 1:
168
            return rows[0]
169
        elif n == 0:
170
            return None
171
        else:
172
            raise ResultException('0 or 1', n, sql)
173
174
    # ------------------------------------------------------------------------------------------------------------------
175
    def execute_row1(self, sql: str, *params) -> Dict[str, Any]: