|
我用了你的代码尝试了一下,出现了一个问题:
/usr/local/bin/python3.7 /Users/yq37222/PycharmProjects/untitled1/.idea/cp.py
Traceback (most recent call last):
File "/Users/yq37222/PycharmProjects/untitled1/.idea/cp.py", line 28, in <module>
df.to_sql('listed_company2', con=engine, if_exists='append', index=False)
File "/Library/Frameworks/Python.framework/Versi**/3.7/lib/python3.7/site-packages/pandas/core/generic.py", line 2522, in to_sql
dtype=dtype, method=method)
File "/Library/Frameworks/Python.framework/Versi**/3.7/lib/python3.7/site-packages/pandas/io/sql.py", line 459, in to_sql
chunksize=chunksize, dtype=dtype, method=method)
File "/Library/Frameworks/Python.framework/Versi**/3.7/lib/python3.7/site-packages/pandas/io/sql.py", line 1172, in to_sql
table.create()
File "/Library/Frameworks/Python.framework/Versi**/3.7/lib/python3.7/site-packages/pandas/io/sql.py", line 571, in create
if self.exists():
File "/Library/Frameworks/Python.framework/Versi**/3.7/lib/python3.7/site-packages/pandas/io/sql.py", line 559, in exists
return self.pd_sql.has_table(self.name, self.schema)
File "/Library/Frameworks/Python.framework/Versi**/3.7/lib/python3.7/site-packages/pandas/io/sql.py", line 1200, in has_table
schema or self.meta.schema,
File "/Library/Frameworks/Python.framework/Versi**/3.7/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 2124, in run_callable
with self.contextual_connect() as conn:
File "/Library/Frameworks/Python.framework/Versi**/3.7/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 2192, in contextual_connect
self._wrap_pool_connect(self.pool.connect, None),
File "/Library/Frameworks/Python.framework/Versi**/3.7/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 2228, in _wrap_pool_connect
return fn()
File "/Library/Frameworks/Python.framework/Versi**/3.7/lib/python3.7/site-packages/sqlalchemy/pool.py", line 425, in connect
return _ConnectionFairy._checkout(self)
File "/Library/Frameworks/Python.framework/Versi**/3.7/lib/python3.7/site-packages/sqlalchemy/pool.py", line 822, in _checkout
fairy = _ConnectionRecord.checkout(pool)
File "/Library/Frameworks/Python.framework/Versi**/3.7/lib/python3.7/site-packages/sqlalchemy/pool.py", line 554, in checkout
rec = pool._do_get()
File "/Library/Frameworks/Python.framework/Versi**/3.7/lib/python3.7/site-packages/sqlalchemy/pool.py", line 1250, in _do_get
self._dec_overflow()
File "/Library/Frameworks/Python.framework/Versi**/3.7/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py", line 67, in __exit__
compat.reraise(exc_type, exc_value, exc_tb)
File "/Library/Frameworks/Python.framework/Versi**/3.7/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 277, in reraise
raise value
File "/Library/Frameworks/Python.framework/Versi**/3.7/lib/python3.7/site-packages/sqlalchemy/pool.py", line 1247, in _do_get
return self._create_connection()
File "/Library/Frameworks/Python.framework/Versi**/3.7/lib/python3.7/site-packages/sqlalchemy/pool.py", line 370, in _create_connection
return _ConnectionRecord(self)
File "/Library/Frameworks/Python.framework/Versi**/3.7/lib/python3.7/site-packages/sqlalchemy/pool.py", line 499, in __init__
self.__connect(first_connect_check=True)
File "/Library/Frameworks/Python.framework/Versi**/3.7/lib/python3.7/site-packages/sqlalchemy/pool.py", line 701, in __connect
connection = pool._invoke_creator(self)
File "/Library/Frameworks/Python.framework/Versi**/3.7/lib/python3.7/site-packages/sqlalchemy/engine/strategies.py", line 114, in connect
return dialect.connect(*cargs, **cparams)
File "/Library/Frameworks/Python.framework/Versi**/3.7/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 437, in connect
return self.dbapi.connect(*cargs, **cparams)
File "/Library/Frameworks/Python.framework/Versi**/3.7/lib/python3.7/site-packages/pymysql/__init__.py", line 94, in Connect
return Connection(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versi**/3.7/lib/python3.7/site-packages/pymysql/connecti**.py", line 325, in __init__
self.connect()
File "/Library/Frameworks/Python.framework/Versi**/3.7/lib/python3.7/site-packages/pymysql/connecti**.py", line 583, in connect
**kwargs)
File "/Library/Frameworks/Python.framework/Versi**/3.7/lib/python3.7/socket.py", line 707, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
File "/Library/Frameworks/Python.framework/Versi**/3.7/lib/python3.7/socket.py", line 748, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
TypeError: getaddrinfo() argument 1 must be string or None |
|