Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

267
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda