Title: [973] trunk/docs/contents/pg: Add note about executing multiple SQL commands
- Revision
- 973
- Author
- cito
- Date
- 2019-04-19 16:59:02 -0400 (Fri, 19 Apr 2019)
Log Message
Add note about executing multiple SQL commands
Also mention performance penalty of query_formatted().
Modified Paths
Diff
Modified: trunk/docs/contents/pg/connection.rst (972 => 973)
--- trunk/docs/contents/pg/connection.rst 2019-04-19 19:37:34 UTC (rev 972)
+++ trunk/docs/contents/pg/connection.rst 2019-04-19 20:59:02 UTC (rev 973)
@@ -62,6 +62,10 @@
an effective way to pass arbitrary or unknown data without worrying about
SQL injection or syntax errors.
+If you don't pass any parameters, the command string can also include
+multiple SQL commands (separated by semicolons). You will only get the
+return value for the last command in this case.
+
When the database could not process the query, a :exc:`pg.ProgrammingError` or
a :exc:`pg.InternalError` is raised. You can check the ``SQLSTATE`` error code
of this error by reading its :attr:`sqlstate` attribute.
Modified: trunk/docs/contents/pg/db_wrapper.rst (972 => 973)
--- trunk/docs/contents/pg/db_wrapper.rst 2019-04-19 19:37:34 UTC (rev 972)
+++ trunk/docs/contents/pg/db_wrapper.rst 2019-04-19 20:59:02 UTC (rev 973)
@@ -491,6 +491,18 @@
If you set *inline* to True, the parameters will be sent to the database
embedded in the SQL command, otherwise they will be sent separately.
+If you set *inline* to True or don't pass any parameters, the command string
+can also include multiple SQL commands (separated by semicolons). You will
+only get the return value for the last command in this case.
+
+Note that the adaption and conversion of the parameters causes a certain
+performance overhead. Depending on the type of values, the overhead can be
+smaller for *inline* queries or if you pass the types of the parameters,
+so that they don't need to be guessed from the values. For best performance,
+we recommend using a raw :meth:`DB.query` or :meth:`DB.query_prepared` if you
+are executing many of the same operations with different parameters.
+
+
Example::
name = input("Name? ")
_______________________________________________
PyGreSQL mailing list
[email protected]
https://mail.vex.net/mailman/listinfo/pygresql