On Sun, Jul 08, 2018 at 04:47:47PM +0200, Christoph Zwerschke wrote:
> [...] we can make the query itself iterable; it would then return tuples.

This is already done in my patch (but maybe not as you intend?)

>>> for a in pg.DB(port=5433,dbname='postgres').query('SELECT 1'): print a
...
(1,)

On Sun, Jul 08, 2018 at 12:29:22PM -0400, D'Arcy Cain wrote:
> Overall I am good with it.  One question - would "print(query) still
> display the result in tabular form?

Great question - actually it's been on my todo list to add a test for this in
my branch..

Right now it is (but maybe you're suggesting it shouldn't be?)

>>> print pg.DB(port=5433,dbname='postgres').query('SELECT 1')
?column?
--------
       1
(1 row)

I also wanted to add a test for query_formatted + iteration.

And sequence protocol.

Hmm.  I just noticed this isn't ideal:
>>> for a in pg.DB(port=5433,dbname='postgres').query_formatted('SELECT * FROM 
>>> generate_series(1,9)a WHERE a>%s'): print a
... 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "pg.py", line 1870, in query_formatted
    command, parameters, types, inline))
  File "pg.py", line 1852, in query
    return self.db.query(command, args)
pg.ProgrammingError: ERROR:  column "s" does not exist
LINE 1: SELECT * FROM generate_series(1,9)a WHERE a>%s

Probably a consequence of r899 (which was done at my request).  I guess if the
query has a %s and doesn't have params, pygres should throw an error rather
than shipping the %s to postgres to (probably) fail.

Justin
_______________________________________________
PyGreSQL mailing list
[email protected]
https://mail.vex.net/mailman/listinfo.cgi/pygresql

Reply via email to