question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

peewee.ProgrammingError: missing FROM-clause entry for table "t1"

See original GitHub issue
query3 = Bookchapter.select(
    Bookchapter.id,
    Bookchapter.chapter,
)

Books.insert_from(query3, fields=[
    Books.id,
    Books.chapter
]).on_conflict(
    conflict_target=[Books.id],
    update={Books.chapter: Bookchapter.chapter}
).execute()

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
coleifercommented, Jun 22, 2020

The proper way to write this is to reference the “new” update-value using EXCLUDED. Peewee provides a shortcut, which is the preserve option.

Books.insert_from(query3, fields=[
    Books.id,
    Books.chapter
]).on_conflict(
    conflict_target=[Books.id],
    preserve=[q.c.name]  # Note we're referencing the name here.
)

You can also write:

.on_conflict(
    conflict_target=[Books.id],
    preserve=['name']  # Name of column to preserve ("carry over") from insert.
)
0reactions
coleifercommented, Jun 21, 2020

I thought you said it was not working. Please share the sql to a version of the query that works.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Subquery with joins on complex queries · Issue #1684 - GitHub
And I'm getting invalid SQL: peewee.ProgrammingError: missing FROM-clause entry for table "t3" LINE 1: ...t1"."magazine_id" = "t2"."id") INNER ...
Read more >
sql - Create subquery using peewee, using `.select` on the ...
peewee.ProgrammingError: missing FROM-clause entry for table "solutions_subquery" LINE 1: ...EFT OUTER JOIN "solution" AS "t1" ON ("t1".
Read more >
Relationships and Joins — peewee 3.15.4 documentation
Peewee allows you to join on any table-like object, including subqueries or common table expressions (CTEs). To demonstrate joining on a subquery, let's...
Read more >
Peewee - Quick Guide - Tutorialspoint
Peewee - Quick Guide, Peewee is a Python Object Relational Mapping (ORM) ... It is possible to retrieve data from SQLite table by...
Read more >
API Documentation — peewee 3.15.4 documentation
def on_app_startup(): # When app starts up, create the database tables, ... data_type='INTEGER', null=False, primary_key=True, table='entry'), ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found