Я пытаюсь запустить следующий код в Google Colab, но получаю сообщение об ошибке 'EOF в многострочной строке'
import sqlite3
from google.colab import files
uploaded = files.upload()
#upload file Db-IMDB.db
connection = sqlite3.connect('./Db-IMDB.db')
Yash = pd.read_sql_query("""SELECT da.*
FROM (SELECT pd.pid, pd.name as Director, pa.pid, pa.name as actor, COUNT(*) as cnt,
RANK() OVER (PARTITION BY pa.pid ORDER BY COUNT(*) DESC) as seqnum,
COUNT(*) OVER (PARTITION BY pa.pid, COUNT(*)) as num_with_cnt,
FROM M_director d JOIN
Person pd
ON pd.pid = d.pid JOIN
M_cast c
ON c.MID = d.MID JOIN
Person pa
ON pa.PID = c.PID
GROUP BY pd.pid, pd.name, pa.pid, pa.name
) da
WHERE director = 'Yash Chopra' AND
seqnum = 1 AND
num_with_cnt = 1;""",connection)
print(Yash)
Я просмотрел запросы других пользователей наэта ошибка, из того, что я видел, всегда связана с отсутствующей апострафией '
, однако я проверил свой код и не пропустил ни одного.Не могли бы вы помочь мне выяснить, что является причиной ошибки?
Мои ссылки: Ошибка токена: EOF в многострочном выражении Получение ошибки при загрузке файла CSV в фрейм данных с использованием Jupyterзаписная книжка
Полная ошибка:
ERROR:root:An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line string', (1, 23))
---------------------------------------------------------------------------
OperationalError Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/pandas/io/sql.py in execute(self, *args, **kwargs)
1430 else:
-> 1431 cur.execute(*args)
1432 return cur
OperationalError: near "(": syntax error
During handling of the above exception, another exception occurred:
DatabaseError Traceback (most recent call last)
5 frames
/usr/local/lib/python3.6/dist-packages/pandas/io/sql.py in execute(self, *args, **kwargs)
1429 cur.execute(*args, **kwargs)
1430 else:
-> 1431 cur.execute(*args)
1432 return cur
1433 except Exception as exc:
DatabaseError: Execution failed on sql 'SELECT da.*
FROM (SELECT pd.pid, pd.name as Director, pa.pid, pa.name as actor, COUNT(*) as cnt,
RANK() OVER (PARTITION BY pa.pid ORDER BY COUNT(*) DESC) as seqnum,
COUNT(*) OVER (PARTITION BY pa.pid, COUNT(*)) as num_with_cnt,
FROM M_director d JOIN
Person pd
ON pd.pid = d.pid JOIN
M_cast c
ON c.MID = d.MID JOIN
Person pa
ON pa.PID = c.PID
GROUP BY pd.pid, pd.name, pa.pid, pa.name
) da
WHERE director = 'Yash Chopra' AND
seqnum = 1 AND
num_with_cnt = 1;': near "(": syntax error