Ich versuche einfach meine Abfragen und deren Parameter mit der Funktion pYMYSQL.CURSOR.MOGRIFY () wie in der Dokumentation detaillierter detailliert zu protokollieren.
python-1 | INFO:__main__:Creating records.
python-1 | INFO:trex.confluence.main:Creating templates with [{'template_name': 'Phil Test 001', 'template_data': 'Farts
This is a template
'}, {'template_name': 'Phil Test 002', 'template_data': 'Farts
This is a template
'}]
python-1 | INFO:trex.confluence.db:Creating templates with [{'template_name': 'Phil Test 001', 'template_data': 'Farts
This is a template
'}, {'template_name': 'Phil Test 002', 'template_data': 'Farts
This is a template
'}]
python-1 | INFO:trex.confluence.db:Creating DB Client
python-1 | INFO:trex.confluence.db:Setting up local dev client.
python-1 | INFO:trex.confluence.db:Running SQL Query: INSERT INTO confluence_templates (name, template)
python-1 | VALUES (%(template_name)s, %(template_data)s);
python-1 | INFO:trex.confluence.db:Executing many SQL Queries. Processing the SQL Query: INSERT INTO confluence_templates (name, template)
python-1 | VALUES (%(template_name)s, %(template_data)s);, and Parameters: [{'template_name': 'Phil Test 001', 'template_data': 'Farts
This is a template
'}, {'template_name': 'Phil Test 002', 'template_data': 'Farts
This is a template
'}]
Hier soll der mogrify () passieren, aber stattdessen erhalten wir den Fehler. Oben werden Sie sehen, welche Abfrage ich übergeben und welche Argumente. Ohne die mogrifizierte Methode funktioniert der Executemany () gut.
python-1 | File "/app/trex/confluence/db.py", line 157, in run_query
python-1 | logger.info(db_curr.mogrify(query=sql_query, args=kwargs.get('parameters')))
python-1 | ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
python-1 | File "/usr/local/lib/python3.13/site-packages/pymysql/cursors.py", line 129, in mogrify
python-1 | query = query % self._escape_args(args, conn)
python-1 | ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
python-1 | File "/usr/local/lib/python3.13/site-packages/pymysql/cursors.py", line 102, in _escape_args
python-1 | return tuple(conn.literal(arg) for arg in args)
python-1 | File "/usr/local/lib/python3.13/site-packages/pymysql/cursors.py", line 102, in
python-1 | return tuple(conn.literal(arg) for arg in args)
python-1 | ~~~~~~~~~~~~^^^^^
python-1 | File "/usr/local/lib/python3.13/site-packages/pymysql/connections.py", line 530, in literal
python-1 | return self.escape(obj, self.encoders)
python-1 | ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
python-1 | File "/usr/local/lib/python3.13/site-packages/pymysql/connections.py", line 523, in escape
python-1 | return converters.escape_item(obj, self.charset, mapping=mapping)
python-1 | ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
python-1 | File "/usr/local/lib/python3.13/site-packages/pymysql/converters.py", line 23, in escape_item
python-1 | val = encoder(val, charset, mapping)
python-1 | File "/usr/local/lib/python3.13/site-packages/pymysql/converters.py", line 30, in escape_dict
python-1 | raise TypeError("dict can not be used as parameter")
python-1 | TypeError: dict can not be used as parameter
Wie Sie jedoch aus den Protokollen sehen können, sende ich an mogrify () eine Zeichenfolge für meine Abfrage und eine Liste für meine ARGS zu interpolieren. In der Dokumentation heißt es jedoch, dass dies funktionieren sollte. Ich folge dem Code nicht wirklich gut in Github, es macht für mich keinen Sinn.
import logging
import pymysql
import pymysql.cursors
sql_query = r"""INSERT INTO confluence_templates (name, template) VALUES (%(template_name)s, %(template_data)s);"""
parameters = [{'template_name': 'Phil Test 001', 'template_data': 'Farts
This is a template
'},
{'template_name': 'Phil Test 002', 'template_data': 'Farts
This is a template
'}]
db_conn = pymysql.connect(host="mysql",
user="trexdev",
password="mysupersecretpassword",
db="trex_confluence",
port=3306,
cursorclass=pymysql.cursors.DictCursor,
charset='utf8')
with db_conn:
with db_conn.cursor() as db_curr:
logging.info(db_curr.mogrify(query=sql_query, args=parameters))
db_curr.execute(query=sql_query, args=parameters)
db_conn.commit()
Ich versuche einfach meine Abfragen und deren Parameter mit der Funktion pYMYSQL.CURSOR.MOGRIFY () wie in der Dokumentation detaillierter detailliert zu protokollieren.[code]python-1 | INFO:__main__:Creating records. python-1 | INFO:trex.confluence.main:Creating templates with [{'template_name': 'Phil Test 001', 'template_data': 'Farts This is a template '}, {'template_name': 'Phil Test 002', 'template_data': 'Farts This is a template '}] python-1 | INFO:trex.confluence.db:Creating templates with [{'template_name': 'Phil Test 001', 'template_data': 'Farts This is a template '}, {'template_name': 'Phil Test 002', 'template_data': 'Farts This is a template '}] python-1 | INFO:trex.confluence.db:Creating DB Client python-1 | INFO:trex.confluence.db:Setting up local dev client. python-1 | INFO:trex.confluence.db:Running SQL Query: INSERT INTO confluence_templates (name, template) python-1 | VALUES (%(template_name)s, %(template_data)s);
python-1 | INFO:trex.confluence.db:Executing many SQL Queries. Processing the SQL Query: INSERT INTO confluence_templates (name, template) python-1 | VALUES (%(template_name)s, %(template_data)s);, and Parameters: [{'template_name': 'Phil Test 001', 'template_data': 'Farts This is a template '}, {'template_name': 'Phil Test 002', 'template_data': 'Farts This is a template '}] [/code] Hier soll der mogrify () passieren, aber stattdessen erhalten wir den Fehler. Oben werden Sie sehen, welche Abfrage ich übergeben und welche Argumente. Ohne die mogrifizierte Methode funktioniert der Executemany () gut.[code]python-1 | ERROR:flaskapp:Exception on /api/templates [POST] python-1 | Traceback (most recent call last): python-1 | File "/usr/local/lib/python3.13/site-packages/flask/app.py", line 1511, in wsgi_app python-1 | response = self.full_dispatch_request() python-1 | File "/usr/local/lib/python3.13/site-packages/flask/app.py", line 919, in full_dispatch_request python-1 | rv = self.handle_user_exception(e) python-1 | File "/usr/local/lib/python3.13/site-packages/flask/app.py", line 917, in full_dispatch_request python-1 | rv = self.dispatch_request() python-1 | File "/usr/local/lib/python3.13/site-packages/flask/app.py", line 902, in dispatch_request python-1 | return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return] python-1 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^ python-1 | File "/app/flaskapp.py", line 87, in templates python-1 | cf_templates = trex.confluence.create_templates(request.get_json()) python-1 | File "/app/trex/confluence/main.py", line 177, in create_templates python-1 | cf_templates = trex.confluence.db.create_templates(page_data=page_data) python-1 | File "/app/trex/confluence/db.py", line 392, in create_templates python-1 | cf_templates = run_query(sql_query=sql_query, parameters=page_data) [/code] Hier wird der mogrify () in der Stack-Trace ausgeführt.[code]python-1 | File "/app/trex/confluence/db.py", line 157, in run_query python-1 | logger.info(db_curr.mogrify(query=sql_query, args=kwargs.get('parameters'))) python-1 | ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ python-1 | File "/usr/local/lib/python3.13/site-packages/pymysql/cursors.py", line 129, in mogrify python-1 | query = query % self._escape_args(args, conn) python-1 | ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^ python-1 | File "/usr/local/lib/python3.13/site-packages/pymysql/cursors.py", line 102, in _escape_args python-1 | return tuple(conn.literal(arg) for arg in args) python-1 | File "/usr/local/lib/python3.13/site-packages/pymysql/cursors.py", line 102, in python-1 | return tuple(conn.literal(arg) for arg in args) python-1 | ~~~~~~~~~~~~^^^^^ python-1 | File "/usr/local/lib/python3.13/site-packages/pymysql/connections.py", line 530, in literal python-1 | return self.escape(obj, self.encoders) python-1 | ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^ python-1 | File "/usr/local/lib/python3.13/site-packages/pymysql/connections.py", line 523, in escape python-1 | return converters.escape_item(obj, self.charset, mapping=mapping) python-1 | ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ python-1 | File "/usr/local/lib/python3.13/site-packages/pymysql/converters.py", line 23, in escape_item python-1 | val = encoder(val, charset, mapping) python-1 | File "/usr/local/lib/python3.13/site-packages/pymysql/converters.py", line 30, in escape_dict python-1 | raise TypeError("dict can not be used as parameter") python-1 | TypeError: dict can not be used as parameter [/code] Wie Sie jedoch aus den Protokollen sehen können, sende ich an mogrify () eine Zeichenfolge für meine Abfrage und eine Liste für meine ARGS zu interpolieren. In der Dokumentation heißt es jedoch, dass dies funktionieren sollte. Ich folge dem Code nicht wirklich gut in Github, es macht für mich keinen Sinn.[code]import logging import pymysql import pymysql.cursors
sql_query = r"""INSERT INTO confluence_templates (name, template) VALUES (%(template_name)s, %(template_data)s);"""
parameters = [{'template_name': 'Phil Test 001', 'template_data': 'Farts This is a template '}, {'template_name': 'Phil Test 002', 'template_data': 'Farts This is a template '}]
with db_conn: with db_conn.cursor() as db_curr: logging.info(db_curr.mogrify(query=sql_query, args=parameters)) db_curr.execute(query=sql_query, args=parameters)
Ich versuche, mein Jupyter-Notizbuch als PDF zu erstellen, erhalte jedoch immer die folgende Fehlermeldung:
Wenn Sie xelatex (TeX) nicht installiert haben, müssen Sie dies vor Ihnen tun kann als PDF...
Ich versuche, Daten aus der Ausnahmetabelle abzurufen und dann die Änderungen in der Tabelle „master_one“ zu bearbeiten, aber die Commits funktionieren nicht.
Wenn ich eine Update-Anweisung hart...
Bildbeschreibung hier eingeben. First hier ... jeder sagt, dass Flask die beste Community über Überlauf hat. Bitte helfen Sie mir ... Ich möchte meine Flask -App bereitstellen. Alle Regeln folgten,...
Bildbeschreibung hier eingeben. First hier ... jeder sagt, dass Flask die beste Community über Überlauf hat. Bitte helfen Sie mir ... Ich möchte meine Flask -App bereitstellen. Alle Regeln folgten,...
Ich habe meine Testfälle abhängig davon aktualisiert (wie nachstehend in Code -Snippet angegeben), seitdem bin ich mit diesem Fehler von Java.lang.NullPointerexception: Die Onaktivität kann nicht...