RE: New user questions

2021-07-14 Thread Rich Shepard
On Wed, 14 Jul 2021, David Raymond wrote: "The module contains objects and functions useful to generate SQL dynamically, in a convenient and safe way." David, There are many examples in the doc and I'm just learning which is appropriate for each of my queries. If there's nothing dynamic abo

Re: New user questions

2021-07-14 Thread Rich Shepard
On Wed, 14 Jul 2021, Adrian Klaver wrote: Where are c.nbr and a.* coming from? If they are supposed to be table qualified values this will not work. Adrian, From the psql shell version. Also it is sql.Identifier. Thanks; I certainly missed that. This will not work, if for no other rea

RE: New user questions

2021-07-14 Thread David Raymond
From https://www.psycopg.org/docs/sql.html "The module contains objects and functions useful to generate SQL dynamically, in a convenient and safe way." If there's nothing dynamic about the text of the query, then you don't really need to go through all the trouble of using all those classes. T

Re: New user questions

2021-07-14 Thread Adrian Klaver
On 7/14/21 10:57 AM, Adrian Klaver wrote: On 7/14/21 10:35 AM, Rich Shepard wrote: This will not work, if for no other reason that 'companies as c on c.org_nbr = p.org_nbr', etc are not identifiers and it is sql.Identifier. Also it would be simpler for this case just to create a quoted stat

Re: New user questions

2021-07-14 Thread Adrian Klaver
On 7/14/21 10:35 AM, Rich Shepard wrote: On Tue, 13 Jul 2021, Adrian Klaver wrote: Then you want to take a look at this: https://www.psycopg.org/docs/sql.html Adrian, Based on pages 1-2 of that doc I've re-written one each of an insert and select query. When they are correct I'll do the rest

Re: New user questions

2021-07-14 Thread Rich Shepard
On Tue, 13 Jul 2021, Adrian Klaver wrote: Then you want to take a look at this: https://www.psycopg.org/docs/sql.html Adrian, Based on pages 1-2 of that doc I've re-written one each of an insert and select query. When they are correct I'll do the rest of the insert and select queries. Query

Re: New user questions

2021-07-13 Thread Adrian Klaver
On 7/13/21 3:02 PM, Rich Shepard wrote: On Tue, 13 Jul 2021, Adrian Klaver wrote: Triple quoting is used when the statement extends across more then one line. Pair of double quotes is used for single line statement, especially when there are single quoted values in the statement. Adrian, Tha

Re: New user questions

2021-07-13 Thread Rich Shepard
On Tue, 13 Jul 2021, Adrian Klaver wrote: Triple quoting is used when the statement extends across more then one line. Pair of double quotes is used for single line statement, especially when there are single quoted values in the statement. Adrian, That makes sense: the statements are treated

Re: New user questions

2021-07-13 Thread Adrian Klaver
On 7/13/21 1:09 PM, Rich Shepard wrote: I'm starting to learn psycopg2 and have read the basic module usage doc. Two questions on syntax: 1) I've seen a number of psycopg2 cursor execute examples where the select or insert statement is enclosed in a pydoc pair of three double quotes. Most exa