Функция Pandas read_sql_query не работает

Я настроил подключение к базе данных и sql-запрос в функции pandas read sql query, но когда функция выполняется, она выдает ошибку.

def fetchDbTable(candidate_id):
    start_time = time.time()
    # candidate_id = 793
    schema = env_config.get("DEV_DB_SCHEMA_PUBLIC")

    # Create Db engine
    engine = createEngine(
        user=env_config.get("DEV_DB_USER"),
        pwd=env_config.get("DEV_DB_PASSWORD"),
        host=env_config.get("DEV_DB_HOST"),
        db=env_config.get("DEV_DB_NAME"),
    )


    # Create query for resume
    query_resume = (
        """
        select
        a.*,
        b.*,
        c.*

        from
        """
        + schema
        + """.resume_intl_candidate_info a,
        """
        + schema
        + """.resume_intl_candidate_resume b,
        """
        + schema
        + """.resume_intl_candidate_work_experience c

        where
        a.c_id = b.c_id_fk_id
        --and a.c_id = c.c_id_fk_id
        and b.r_id = c.r_id_fk_id
        and b.active_flag = 't'
        and a.c_id = """
        + str(candidate_id)
    )

    # Fetch database
    df_resume = pd.read_sql_query(query_resume, con=engine)

pandas текущая версия - 1.5.2, numpy текущая версия - 1.23.5 в локальном

но версия, используемая в сервере, pandas - 0.23.0, numpy = 1.16.5

Мне нужно изменить код для последней версии и запустить его без ошибки.

Можете ли вы, пожалуйста, помочь мне решить проблему Я потратил более 2 дней и не смог прийти к решению.

Ошибка, бросаемая как:

Traceback (most recent call last):
  File "/home/vinoth/Documents/Req_Intelligence-master/Req_Intelligence-master/req_intl/resume_intl/extractedfields.py", line 483, in save_create_document
    meta_df = fetchDbTable(candidate_info.c_id)
  File "/home/vinoth/Documents/Req_Intelligence-master/Req_Intelligence-master/req_intl/resume_intl/candidate_meta_info.py", line 132, in fetchDbTable
    df_resume = pd.read_sql_query(query_resume, con=engine)
  File "/home/vinoth/.local/lib/python3.10/site-packages/pandas/io/sql.py", line 397, in read_sql_query
    return pandas_sql.read_query(
  File "/home/vinoth/.local/lib/python3.10/site-packages/pandas/io/sql.py", line 1575, in read_query
    frame = _wrap_result(
  File "/home/vinoth/.local/lib/python3.10/site-packages/pandas/io/sql.py", line 151, in _wrap_result
    frame = _parse_date_columns(frame, parse_dates)
  File "/home/vinoth/.local/lib/python3.10/site-packages/pandas/io/sql.py", line 126, in _parse_date_columns
    for col_name, df_col in data_frame.items():
  File "/home/vinoth/.local/lib/python3.10/site-packages/pandas/core/frame.py", line 1325, in items
    yield k, self._ixs(i, axis=1)
  File "/home/vinoth/.local/lib/python3.10/site-packages/pandas/core/frame.py", line 3728, in _ixs
    col_mgr = self._mgr.iget(i)
  File "/home/vinoth/.local/lib/python3.10/site-packages/pandas/core/internals/managers.py", line 1136, in iget
    values = block.iget(self.blklocs[i])
  File "/home/vinoth/.local/lib/python3.10/site-packages/pandas/core/internals/blocks.py", line 834, in iget
    return self.values[i]  # type: ignore[index]
  File "/home/vinoth/.local/lib/python3.10/site-packages/pandas/core/arrays/datetimelike.py", line 358, in __getitem__
    "Union[DatetimeLikeArrayT, DTScalarOrNaT]", super().__getitem__(key)
  File "/home/vinoth/.local/lib/python3.10/site-packages/pandas/core/arrays/_mixins.py", line 289, in __getitem__
    result = self._ndarray[key]
IndexError: index 1 is out of bounds for axis 0 with size 1

Вернуться на верх