-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Michael Bayer ha scritto:
> On Feb 28, 2010, at 11:21 AM, Manlio Perillo wrote:
> 
> I would like to write a patch for ticket #877.
> 

Sorry, I forgot to update the log level used in the patch (I was doing
some tests with the engine `echo` parameter).

Attached is the correct patch.


Manlio
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkuKqbMACgkQscQJ24LbaUQd+wCeOlUulbQoP9KO/EJrd9ZgLUCa
irsAnipmXxMXQwnaWe0bIcZDbCuF5Ml6
=MNXe
-----END PGP SIGNATURE-----
-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

diff --git a/lib/sqlalchemy/dialects/postgresql/psycopg2.py b/lib/sqlalchemy/dialects/postgresql/psycopg2.py
--- a/lib/sqlalchemy/dialects/postgresql/psycopg2.py
+++ b/lib/sqlalchemy/dialects/postgresql/psycopg2.py
@@ -46,8 +46,10 @@
 
 """
 
-import random, re
+import random
+import re
 import decimal
+import logging
 
 from sqlalchemy import util
 from sqlalchemy import processors
@@ -59,6 +61,10 @@
                                             PGIdentifierPreparer, PGExecutionContext, \
                                             ENUM, ARRAY
 
+
+logger = logging.getLogger('sqlalchemy.dialects.postgresql')
+
+
 class _PGNumeric(sqltypes.Numeric):
     def bind_processor(self, dialect):
         return None
@@ -135,6 +141,14 @@
         else:
             return base.ResultProxy(self)
 
+    def post_exec(self):
+        if logger.isEnabledFor(logging.INFO):
+            for notice in self._connection.connection.notices:
+                # NOTICE messages have a newline character at the end
+                logger.info(notice.rstrip())
+
+            self._connection.connection.notices[:] = []
+
 
 class PostgreSQL_psycopg2Compiler(PGCompiler):
     def visit_mod(self, binary, **kw):

Reply via email to