[Python] error: Pandas requires version '1.4.16' or newer of 'sqlalchemy' (version '0.9.8'...

Discussão em 'Python' iniciado por Stack, Fevereiro 15, 2025.

  1. Stack

    Stack Membro Participativo

    I am using sqlalchemy to access my sql database and making changes in sql database, the code for the requirement is:

    output_db_engine=create_engine(
    "mssql+pymssql://{user}:{pw}@{ip}/{db}".format(
    user=PORTAL_DB_USERNAME, pw=urllib.parse.quote_plus(PORTAL_DB_PASSWORD), db=smartsearch_db_name,
    ip=smartsearch_db_ip
    )
    )
    final_df.insert(loc=0, column='Id', value=np.arange(1, len(final_df) + 1))
    final_df.to_sql('Smart_Search_Table', con=output_db_engine,
    chunksize=900,
    method='multi', if_exists='replace', index=False)
    # Making Id column as Primary Key in table
    with output_db_engine.connect() as con:
    con.execute('ALTER TABLE ' + 'Smart_Search_Table' + ' ALTER COLUMN Id INT NOT NULL')
    con.execute('ALTER TABLE ' + 'Smart_Search_Table' + ' ADD PRIMARY KEY (Id);')
    print(
    f"SUCCESS : Table with name Smart_Search_Table is created and loaded with new data "
    )
    return final_df

    if __name__ == "__main__":
    i = making_table()
    i.making_final_df()


    But i am getting an error: ImportError: Unable to find a usable engine; tried using: 'sqlalchemy'. A suitable version of sqlalchemy is required for sql I/O support. Trying to import the above resulted in these errors:

    • Pandas requires version '1.4.16' or newer of 'sqlalchemy' (version '0.9.8' currently installed).

    Can anyone help me to resolve this error?

    I am also getting a warning: A NumPy version >=1.16.5 and <1.23.0 is required for this version of SciPy (detected version 1.24.1 warnings.warn(f"A NumPy version >={np_minversion} and <{np_maxversion}".

    I am new to python, can anyone help me how to resolve these versions mismatch error?

    Continue reading...

Compartilhe esta Página