You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For example in c++ project using python3 c api, does not exist the sys.argv object when call pymysql.connect(). From C api call as module, is not called from cli/interpreter.
For /usr/local/lib/python3.6/site-packages/pymysql/connections.py in line 321:
if program_name:
self._connect_attrs["program_name"] = program_name
elif sys.argv:
self._connect_attrs["program_name"] = sys.argv[0]
Error message:
module 'sys' has no attribute 'argv'.
File "/....py", line 37, in mysqlConnect
File "/usr/local/lib/python3.6/site-packages/pymysql/__init__.py", line 94, in Connect
return Connection(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/pymysql/connections.py", line 321, in __init__
elif sys.argv:
The solution for me: Simulate the argv:
import pymysql
# For pymysql bug
import sys
import os
sys.argv=[os.path.realpath(__file__)]
...
You need replace:
elif sys.argv:
By:
elif callable(getattr(sys, 'argv')) and sys.argv:
...
else:
... Canot get the application name exception or set a application name by default.
Realy need the python script path for a mysql connection?
The text was updated successfully, but these errors were encountered:
methane
added a commit
to methane/PyMySQL
that referenced
this issue
Oct 27, 2018
Uh oh!
There was an error while loading. Please reload this page.
For example in c++ project using python3 c api, does not exist the sys.argv object when call
pymysql.connect()
. From C api call as module, is not called from cli/interpreter.For /usr/local/lib/python3.6/site-packages/pymysql/connections.py in line 321:
Error message:
The solution for me: Simulate the argv:
You need replace:
By:
Realy need the python script path for a mysql connection?
The text was updated successfully, but these errors were encountered: