我想将熊猫df的数据库转换为sqlite3
我正在使用这段代码:
con = sqlite3.connect('\path\db.db')
df = pd.read_sql('select * from db', con)
引用我得到了什么
Traceback (most recent call last):
df = pd.read_sql('select * from db', con)
File "PATH\pandas\io\sql.py", line 403, in read_sql
pandas_sql = pandasSQL_builder(con)
File "PATH\pandas\io\sql.py", line 578, in pandasSQL_builder
if _is_sqlalchemy_connectable(con):
File "PATH\pandas\io\sql.py", line 43, in _is_sqlalchemy_connectable
import sqlalchemy
File "PATHPython38-32\lib\site-packages\sqlalchemy\__init__.py", line 12, in <module>
from sqlalchemy.sql import (
File "PATHPython38-32\lib\site-packages\sqlalchemy\sql\__init__.py", line 7, in <module>
from sqlalchemy.sql.expression import (
File "PATHPython38-32\lib\site-packages\sqlalchemy\sql\expression.py", line 32, in <module>
from sqlalchemy import util, exc
File "PATHPython38-32\lib\site-packages\sqlalchemy\util\__init__.py", line 7, in <module>
from .compat import callable, cmp, reduce, defaultdict, py25_dict, \
File "PATHPython38-32\lib\site-packages\sqlalchemy\util\compat.py", line 202, in <module>
time_func = time.clock
AttributeError: module 'time' has no attribute 'clock'
此代码是否有问题?此错误的原因是什么?
答案 0 :(得分:1)
SQLALchemy 0.7.10确实很老。大概6.5岁。它使用了time.clock
……
:1:DeprecationWarning:time.clock在Python 3.3中已弃用,将从Python 3.8中删除:改用time.perf_counter或time.process_time