text
stringlengths 0
828
|
---|
"""""" |
responses = [] |
for _parser in parsers: |
response = _parser(text = text) |
if response is not False: |
responses.extend(response if response is list else [response]) |
if not any(responses): |
if help_message: |
return help_message |
else: |
return False |
else: |
if len(responses) > 1: |
return responses |
else: |
return responses[0]" |
4762,"def run( |
self |
): |
"""""" |
Engage contained function with optional keyword arguments. |
"""""" |
if self._function and not self._kwargs: |
return self._function() |
if self._function and self._kwargs: |
return self._function(**self._kwargs)" |
4763,"def tax_class_based_on(self, tax_class_based_on): |
""""""Sets the tax_class_based_on of this TaxSettings. |
:param tax_class_based_on: The tax_class_based_on of this TaxSettings. |
:type: str |
"""""" |
allowed_values = [""shippingAddress"", ""billingAddress""] # noqa: E501 |
if tax_class_based_on is not None and tax_class_based_on not in allowed_values: |
raise ValueError( |
""Invalid value for `tax_class_based_on` ({0}), must be one of {1}"" # noqa: E501 |
.format(tax_class_based_on, allowed_values) |
) |
self._tax_class_based_on = tax_class_based_on" |
4764,"def writequery( |
log, |
sqlQuery, |
dbConn, |
Force=False, |
manyValueList=False |
): |
""""""*Execute a MySQL write command given a sql query* |
**Key Arguments:** |
- ``sqlQuery`` -- the MySQL command to execute |
- ``dbConn`` -- the db connection |
- ``Force`` -- do not exit code if error occurs, move onto the next command |
- ``manyValueList`` -- a list of value tuples if executing more than one insert |
**Return:** |
- ``message`` -- error/warning message |
**Usage:** |
Here's an example of how to create a table using the database connection passed to the function: |
.. code-block:: python |
from fundamentals.mysql import writequery |
sqlQuery = ""CREATE TABLE `testing_table` (`id` INT NOT NULL, PRIMARY KEY (`id`))"" |
message = writequery( |
log=log, |
sqlQuery=sqlQuery, |
dbConn=dbConn, |
Force=False, |
manyValueList=False |
) |
Here's a many value insert example: |
.. code-block:: python |
from fundamentals.mysql import writequery |
sqlQuery = ""INSERT INTO testing_table (id) values (%s)"" |
message = writequery( |
log=log, |
sqlQuery=sqlQuery, |
dbConn=dbConn, |
Force=False, |
manyValueList=[(1,), (2,), (3,), (4,), (5,), (6,), (7,), |
(8,), (9,), (10,), (11,), (12,), ] |
) |
"""""" |
log.debug('starting the ``writequery`` function') |
import pymysql |
import warnings |
warnings.filterwarnings('error', category=pymysql.Warning) |
message = """" |
try: |
cursor = dbConn.cursor(pymysql.cursors.DictCursor) |
except Exception as e: |
log.error('could not create the database cursor.') |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.