I'am trying to read sqlite3 database using pandas. Unfortunately in my code is SyntaxError but i can't find it.
The code is the same as in many tutorials so i don't know where is the problem
import pandas as pd
import sqlite3
con = sqlite3.connect("activity_log.db")
query = "SELECT * from log"
df = pd.read_sql_query(query, con)
print(df)
con.close()
result:
" Traceback (most recent call last):
File "C:/Users/g50-45/Desktop/ML/1z10_webapp/data_analyser.py", line 7, in <module>
df = pd.read_sql_query(query, con)
File "C:\Users\g50-45\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\io\sql.py", line 325, in read_sql_query
pandas_sql = pandasSQL_builder(con)
File "C:\Users\g50-45\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\io\sql.py", line 575, in pandasSQL_builder
if _is_sqlalchemy_connectable(con):
File "C:\Users\g50-45\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\io\sql.py", line 44, in _is_sqlalchemy_connectable
import sqlalchemy
File "C:\Users\g50-45\AppData\Local\Programs\Python\Python37-32\lib\site-packages\sqlalchemy\__init__.py", line 12, in <module>
from sqlalchemy.sql import (
File "C:\Users\g50-45\AppData\Local\Programs\Python\Python37-32\lib\site-packages\sqlalchemy\sql\__init__.py", line 7, in <module>
from sqlalchemy.sql.expression import (
File "C:\Users\g50-45\AppData\Local\Programs\Python\Python37-32\lib\site-packages\sqlalchemy\sql\expression.py", line 2452
^
SyntaxError: invalid syntax "
The sqlalchemy package looks like 6 years old (sqlalchemy\sql\expression.py.py", line 2452
), before an important refactoring.
You should remove this package and reinstall it with a newer version or try an update with:
pip install SQLAlchemy --upgrade
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With