Attribute ‘clock’ is missing in the ‘time’ module of pandas while using Sqlite3

One possible solution is to remove a certain file from the folder where the error is occurring and then run the program again, which worked for someone experiencing the same issue. However, while handling the exception, another one occurred, suggesting that at the very least, the package should be updated. Another approach is to update a specific element, which someone had to do to resolve a similar issue, although they still faced problems even after doing so.

Question:

My objective is to convert my database into

sqlite3

suitable for pandas dataframe.

I’m using this piece of code:

con = sqlite3.connect('pathdb.db')
df = pd.read_sql('select * from db', con)

Trackback what I got:

Traceback (most recent call last):
    df = pd.read_sql('select * from db', con)
  File "PATHpandasiosql.py", line 403, in read_sql
    pandas_sql = pandasSQL_builder(con)
  File "PATHpandasiosql.py", line 578, in pandasSQL_builder
    if _is_sqlalchemy_connectable(con):
  File "PATHpandasiosql.py", line 43, in _is_sqlalchemy_connectable
    import sqlalchemy
  File "PATHPython38-32libsite-packagessqlalchemy__init__.py", line 12, in 
    from sqlalchemy.sql import (
  File "PATHPython38-32libsite-packagessqlalchemysql__init__.py", line 7, in 
    from sqlalchemy.sql.expression import (
  File "PATHPython38-32libsite-packagessqlalchemysqlexpression.py", line 32, in 
    from sqlalchemy import util, exc
  File "PATHPython38-32libsite-packagessqlalchemyutil__init__.py", line 7, in 
    from .compat import callable, cmp, reduce, defaultdict, py25_dict, 
  File "PATHPython38-32libsite-packagessqlalchemyutilcompat.py", line 202, in 
    time_func = time.clock
AttributeError: module 'time' has no attribute 'clock'

Is this code malfunctioning? What is causing the error?



Solution:

The version of SQLAlchemy that is being referred to, 0.7.10, is quite outdated. In fact, it was released over six years ago and utilized the

time.clock

syntax.

The usage of time.clock in Python 3.3 is deprecated and will be eliminated from Python 3.8. Instead, time.perf_counter or time.process_time should be used. A DeprecationWarning will be raised if time.clock is still used.

Frequently Asked Questions