Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

266
Vistas
No such table error when replacing a table through SQLalchemy?

I am using SQLalchemy and the pandas method pd.to_sql(if_exists="replace") to insert data in to a table in PostgreSQL.

Now, if the table doesn't exist, then everything works ok.

But, if the table already exists (I know it exists since I can see it in pgAdmin), I get the following error: sqlalchemy.exc.NoSuchTableError:

SQLalchemy is trying to drop this table to replace it with the new one, but it can't find the table for some reason?

Here is a snippet of the code:

ENGINE = create_engine(...)

with ENGINE.begin() as con:
   df.to_sql("table_name", con=con, index=False, if_exists="replace")

This throws the above error? I have tried specifying the schema but this also throws the same error.

Why isn't SQLalchemy finding the table even though it's there?

EDIT: If I remove the if_exists="replace", I then get the error: ValueError: Table tablename already exists.

over 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda