There is a classic example: query = Album.select().join(Artist) , but this query does not select the Artist.name field.
How to choose it?
Or how can I combine two tables without a JOIN ?

  • Try query = Album.select(Artist.name, *Album._meta.fields.values()).join(Artist) should select all Album and Artist.name fields. - godva
  • Something fails - the Artist.name field contains the value "None". Then, theoretically and simply, query = Album.select (Artist.name) .join (Artist) should work, but not work - MyNick
  • I check it like this: for k in query: print (k.name) - MyNick
  • Here I have a working query in pure SQLite: SELECT DISTINCT "t1". "artist_id", "t2". "name" FROM "album" AS "t1" INNER JOIN "artist" AS "t2" ON ("t1". "artist_id" = "t2". "id") and you need the same on Peewee - MyNick

0