@@ -306,130 +306,10 @@ def seek(self, offset, whence = 'ABSOLUTE'):
306306 FROM_END will effectively be ABSOLUTE.
307307 """
308308
309- class Statement (
310- Element ,
311- collections .Callable ,
312- collections .Iterable ,
313- ):
309+ class Execution (metaclass = abc .ABCMeta ):
314310 """
315- Instances of `Statement` are returned by the `prepare` method of
316- `Database` instances.
317-
318- A Statement is an Iterable as well as Callable.
319-
320- The Iterable interface is supported for queries that take no arguments at
321- all. It allows the syntax::
322-
323- >>> for x in db.prepare('select * FROM table'):
324- ... pass
311+ The abstract class of execution methods.
325312 """
326- _e_label = 'STATEMENT'
327- _e_factors = ('database' , 'statement_id' , 'string' ,)
328-
329- @property
330- @abc .abstractmethod
331- def statement_id (self ) -> str :
332- """
333- The statment's identifier.
334- """
335-
336- @property
337- @abc .abstractmethod
338- def string (self ) -> object :
339- """
340- The SQL string of the prepared statement.
341-
342- `None` if not available. This can happen in cases where a statement is
343- prepared on the server and a reference to the statement is sent to the
344- client which subsequently uses the statement via the `Database`'s
345- `statement` constructor.
346- """
347-
348- @property
349- @abc .abstractmethod
350- def sql_parameter_types (self ) -> [str ]:
351- """
352- The type of the parameters required by the statement.
353-
354- A sequence of `str` objects stating the SQL type name::
355-
356- ['INTEGER', 'VARCHAR', 'INTERVAL']
357- """
358-
359- @property
360- @abc .abstractmethod
361- def sql_column_types (self ) -> [str ]:
362- """
363- The type of the columns produced by the statement.
364-
365- A sequence of `str` objects stating the SQL type name::
366-
367- ['INTEGER', 'VARCHAR', 'INTERVAL']
368- """
369-
370- @property
371- @abc .abstractmethod
372- def pg_parameter_types (self ) -> [int ]:
373- """
374- The type Oids of the parameters required by the statement.
375-
376- A sequence of `int` objects stating the PostgreSQL type Oid::
377-
378- [27, 28]
379- """
380-
381- @property
382- @abc .abstractmethod
383- def pg_column_types (self ) -> [int ]:
384- """
385- The type Oids of the columns produced by the statement.
386-
387- A sequence of `int` objects stating the SQL type name::
388-
389- [27, 28]
390- """
391-
392- @property
393- @abc .abstractmethod
394- def column_names (self ) -> [str ]:
395- """
396- The attribute names of the columns produced by the statement.
397-
398- A sequence of `str` objects stating the column name::
399-
400- ['column1', 'column2', 'emp_name']
401- """
402-
403- @property
404- @abc .abstractmethod
405- def column_types (self ) -> [type ]:
406- """
407- The Python types of the columns produced by the statement.
408-
409- A sequence of type objects::
410-
411- [<class 'int'>, <class 'str'>]
412- """
413-
414- @property
415- @abc .abstractmethod
416- def parameter_types (self ) -> [type ]:
417- """
418- The Python types expected of parameters given to the statement.
419-
420- A sequence of type objects::
421-
422- [<class 'int'>, <class 'str'>]
423- """
424-
425- @abc .abstractmethod
426- def clone (self ) -> "Statement" :
427- """
428- Create a new statement object using the same factors as `self`.
429-
430- When used for refreshing plans, the new clone should replace references to
431- the original.
432- """
433313
434314 @abc .abstractmethod
435315 def __call__ (self , * parameters : "Positional Parameters" ) -> ["Row" ]:
@@ -585,11 +465,137 @@ def load_chunks(self,
585465 that the operation can be optimized.
586466 """
587467
468+ class Statement (
469+ Element ,
470+ collections .Callable ,
471+ collections .Iterable ,
472+ ):
473+ """
474+ Instances of `Statement` are returned by the `prepare` method of
475+ `Database` instances.
476+
477+ A Statement is an Iterable as well as Callable.
478+
479+ The Iterable interface is supported for queries that take no arguments at
480+ all. It allows the syntax::
481+
482+ >>> for x in db.prepare('select * FROM table'):
483+ ... pass
484+ """
485+ _e_label = 'STATEMENT'
486+ _e_factors = ('database' , 'statement_id' , 'string' ,)
487+
488+ @property
489+ @abc .abstractmethod
490+ def statement_id (self ) -> str :
491+ """
492+ The statment's identifier.
493+ """
494+
495+ @property
496+ @abc .abstractmethod
497+ def string (self ) -> object :
498+ """
499+ The SQL string of the prepared statement.
500+
501+ `None` if not available. This can happen in cases where a statement is
502+ prepared on the server and a reference to the statement is sent to the
503+ client which subsequently uses the statement via the `Database`'s
504+ `statement` constructor.
505+ """
506+
507+ @property
508+ @abc .abstractmethod
509+ def sql_parameter_types (self ) -> [str ]:
510+ """
511+ The type of the parameters required by the statement.
512+
513+ A sequence of `str` objects stating the SQL type name::
514+
515+ ['INTEGER', 'VARCHAR', 'INTERVAL']
516+ """
517+
518+ @property
519+ @abc .abstractmethod
520+ def sql_column_types (self ) -> [str ]:
521+ """
522+ The type of the columns produced by the statement.
523+
524+ A sequence of `str` objects stating the SQL type name::
525+
526+ ['INTEGER', 'VARCHAR', 'INTERVAL']
527+ """
528+
529+ @property
530+ @abc .abstractmethod
531+ def pg_parameter_types (self ) -> [int ]:
532+ """
533+ The type Oids of the parameters required by the statement.
534+
535+ A sequence of `int` objects stating the PostgreSQL type Oid::
536+
537+ [27, 28]
538+ """
539+
540+ @property
541+ @abc .abstractmethod
542+ def pg_column_types (self ) -> [int ]:
543+ """
544+ The type Oids of the columns produced by the statement.
545+
546+ A sequence of `int` objects stating the SQL type name::
547+
548+ [27, 28]
549+ """
550+
551+ @property
552+ @abc .abstractmethod
553+ def column_names (self ) -> [str ]:
554+ """
555+ The attribute names of the columns produced by the statement.
556+
557+ A sequence of `str` objects stating the column name::
558+
559+ ['column1', 'column2', 'emp_name']
560+ """
561+
562+ @property
563+ @abc .abstractmethod
564+ def column_types (self ) -> [type ]:
565+ """
566+ The Python types of the columns produced by the statement.
567+
568+ A sequence of type objects::
569+
570+ [<class 'int'>, <class 'str'>]
571+ """
572+
573+ @property
574+ @abc .abstractmethod
575+ def parameter_types (self ) -> [type ]:
576+ """
577+ The Python types expected of parameters given to the statement.
578+
579+ A sequence of type objects::
580+
581+ [<class 'int'>, <class 'str'>]
582+ """
583+
584+ @abc .abstractmethod
585+ def clone (self ) -> "Statement" :
586+ """
587+ Create a new statement object using the same factors as `self`.
588+
589+ When used for refreshing plans, the new clone should replace references to
590+ the original.
591+ """
592+
588593 @abc .abstractmethod
589594 def close (self ) -> None :
590595 """
591596 Close the prepared statement releasing resources associated with it.
592597 """
598+ Execution .register (Statement )
593599PreparedStatement = Statement
594600
595601class StoredProcedure (
@@ -1169,10 +1175,19 @@ class Connection(Database):
11691175 @abc .abstractmethod
11701176 def connector (self ) -> Connector :
11711177 """
1172- The `Connector` instance facilitating the `Connection` object's
1178+ The :py:class: `Connector` instance facilitating the `Connection` object's
11731179 communication and initialization.
11741180 """
11751181
1182+ @property
1183+ @abc .abstractmethod
1184+ def query (self ) -> Execution :
1185+ """
1186+ The :py:class:`Execution` instance providing a one-shot query interface::
1187+
1188+ connection.query.<method>(sql, *parameters) == connection.prepare(sql).<method>(*parameters)
1189+ """
1190+
11761191 @property
11771192 @abc .abstractmethod
11781193 def closed (self ) -> bool :
0 commit comments