Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An error is reported when the pandas.to_sql() function is used to import data to the database. #716

Open
car1000 opened this issue Jan 21, 2025 · 3 comments

Comments

@car1000
Copy link

car1000 commented Jan 21, 2025

We're using pinpointPy==1.2.0

An error is reported during data processing.

2025-01-21 14:47:12,409 - ERROR F42FC2AB_63FB_4ECA_9170_531D601BFBE0: TypeError: argument 2 must be str, not bytearray

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/root/work/AIC_Noah_ScmOptimization/models/ailab_cbg_dps_service/dps_automation/heuristic.py", line 1753, in run
self.result.run(tracking_id=self.tracking_id, s3h=self.s3h)
File "/root/work/AIC_Noah_ScmOptimization/models/ailab_cbg_dps_service/dps_automation/result.py", line 1097, in run
tb_line_name=d_tables["mdps_solution_bucket"])
File "/root/work/AIC_Noah_ScmOptimization/models/ailab_cbg_dps_service/dps_automation/result.py", line 1155, in export
oe.insert_many(table_name=tb_header_name, df=df_sol_header_db, write_local_db=False)
File "/root/work/AIC_Noah_ScmOptimization/models/ailab_cbg_dps_service/dps_automation/mysql_engine.py", line 186, in insert_many
df.to_sql(table_name, self.sqlachemy_conn, if_exists="append", index=False)
File "/usr/local/lib/python3.6/site-packages/pandas/core/generic.py", line 2531, in to_sql
dtype=dtype, method=method)
File "/usr/local/lib/python3.6/site-packages/pandas/io/sql.py", line 460, in to_sql
chunksize=chunksize, dtype=dtype, method=method)
File "/usr/local/lib/python3.6/site-packages/pandas/io/sql.py", line 1174, in to_sql
table.insert(chunksize, method=method)
File "/usr/local/lib/python3.6/site-packages/pandas/io/sql.py", line 686, in insert
exec_insert(conn, keys, chunk_iter)
File "/usr/local/lib/python3.6/site-packages/pandas/io/sql.py", line 599, in _execute_insert
conn.execute(self.table.insert(), data)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1263, in execute
return meth(self, multiparams, params, _EMPTY_EXECUTION_OPTS)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/sql/elements.py", line 324, in _execute_on_connection
self, multiparams, params, execution_options
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1462, in _execute_clauseelement
cache_hit=cache_hit,
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1815, in execute_context
e, statement, parameters, cursor, context
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1999, in handle_dbapi_exception
util.raise
(exc_info[1], with_traceback=exc_info[2])
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 207, in raise

raise exception
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1752, in _execute_context
cursor, statement, parameters, context
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/dialects/mysql/mysqldb.py", line 197, in do_executemany
rowcount = cursor.executemany(statement, parameters)
File "/usr/local/lib/python3.6/site-packages/pymysql/cursors.py", line 179, in executemany
self._get_db().encoding,
File "/usr/local/lib/python3.6/site-packages/pymysql/cursors.py", line 211, in _do_execute_many
rows += self.execute(sql + postfix)
File "/usr/local/lib/python3.6/site-packages/pinpointPy/Common.py", line 96, in pinpointTrace
parentId, *nArgs, **nKwargs)
File "/usr/local/lib/python3.6/site-packages/pinpointPy/libs/_PyMysql/PyMysqlPlugin.py", line 35, in onBefore
pinpoint.add_trace_header(Defines.PP_SQL_FORMAT, args[1], trace_id)
File "/usr/local/lib/python3.6/site-packages/pinpointPy/pinpoint.py", line 82, in add_trace_header
_pinpointPy.add_clue(key, value, trace_id, location)
SystemError: returned a result with an error set

During handling of the above exception, another exception occurred:

Help me see how to solve this mistake. Thank you very much.
@car1000
Copy link
Author

car1000 commented Jan 21, 2025

The service can be normally displayed in the ppweb, but an error occurs during service processing.

@eeliu
Copy link
Collaborator

eeliu commented Jan 21, 2025

2025-01-21 14:47:12,409 - ERROR F42FC2AB_63FB_4ECA_9170_531D601BFBE0: TypeError: argument 2 must be str, not bytearray

Thanks your feedback ! I will check this old version 1.2.0.

eeliu added a commit to eeliu/pinpoint-c-agent that referenced this issue Jan 24, 2025
@eeliu
Copy link
Collaborator

eeliu commented Jan 24, 2025

@car1000

Can you help us test it ?

pip install -i https://test.pypi.org/simple/ pinpointPy==1.3.8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants