Re: [sqlalchemy] suppress echo of INSERT/UPDATE large binary data

2016-08-17 Thread Mike Bayer



On 08/17/2016 01:25 PM, Kent wrote:

Generally, echo=True for log level of INFO is very helpful for log files.

But on INSERT/UPDATE of a Binary column (at least with Oracle, BLOB) it
sure would be nice to skip the logging of the sometimes massive binary data.

Is this possible?


http://docs.sqlalchemy.org/en/latest/changelog/migration_11.html#large-parameter-and-row-values-are-now-truncated-in-logging-and-exception-displays

until you can upgrade write a logging output filter...





Thanks,
Kent

--
You received this message because you are subscribed to the Google
Groups "sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to sqlalchemy+unsubscr...@googlegroups.com
.
To post to this group, send email to sqlalchemy@googlegroups.com
.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


[sqlalchemy] Re: suppress echo of INSERT/UPDATE large binary data

2016-08-17 Thread Jonathan Vanasco


On Wednesday, August 17, 2016 at 1:25:17 PM UTC-4, Kent wrote:
>
> Generally, echo=True for log level of INFO is very helpful for log files.
>

If you just have a few of these, you can wrap the flush:

dbSession.add(bigObject)
try:
# wrap `flush` in a disabled block, so we don't go crazy with logging
logging.getLogger('sqlalchemy.engine.base.Engine').disabled = True
dbSession.flush()
except:
raise
finally:
logging.getLogger('sqlalchemy.engine.base.Engine').disabled = False


If you have a lot, I believe you can use the event listening system to do 
something similar.

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


[sqlalchemy] suppress echo of INSERT/UPDATE large binary data

2016-08-17 Thread Kent
Generally, echo=True for log level of INFO is very helpful for log files.

But on INSERT/UPDATE of a Binary column (at least with Oracle, BLOB) it 
sure would be nice to skip the logging of the sometimes massive binary data.

Is this possible?

Thanks,
Kent

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


[sqlalchemy] Re: Creating declared class in __declare_first__ causes RuntimeError: deque mutated during iteration

2016-08-17 Thread Tom Kedem
Figured it out. It wasn't FlaskSqlalchemy, it was me.
The decalrative base class inherited from References which had the 
__declarefirst__ in it. Trying to instantiate a declarative class (which 
inherited from References) inside __declarefirst__ fired that event, which 
caused the error. I removed the References class from the declarative base 
up the hierarchy (created a base class inheriting from declarative base, 
which is marked with __abstract__=true).
Solved the problem.
Thanks for the support :)
I hope to release my results, once I finish, as part of sqlalchemy utils.

On Monday, August 15, 2016 at 4:38:34 PM UTC+3, Tom Kedem wrote:
>
> I'm trying to create a dynamic many_to_many relationship, inspired by:
> http://techspot.zzzeek.org/2011/05/17/magic-a-new-orm/
>
> https://bitbucket.org/zzzeek/pycon2014_atmcraft/src/f50cbe745a19/atmcraft/model/meta/?at=master
>  
> (orm.py and schema.py)
>
> I've got it working with just creating a secondary table in the 
> __declare_first__ hook.
>
> Now I want it to be a "secondary" class and not just a table - and I'm 
> having trouble.
> I've created a declared class in the __declare_first__ hook. Creating that 
> class causes (Full stacktrace at the bottom):
> RuntimeError: deque mutated during iteration
>
> I suppose new events are being added when I do so. Searching google I came 
> upon these:
>
> https://bitbucket.org/zzzeek/sqlalchemy/issues/3163/use-deque-for-event-lists-so-that-remove
>
> https://bitbucket.org/zzzeek/sqlalchemy/commits/4a4cccfee5a2#Llib/sqlalchemy/event/api.pyT61
>
> But since I'm not creating those events explicitly (I suspect the declared 
> class creates them), I'm not sure about how to proceed.
>
> Full stacktrace if it's helpful:
>   File 
> "C:\Users\vToMy\PycharmProjects\sqlalchemy\lib\sqlalchemy\orm\instrumentation.py",
>  
> line 347, in _new_state_if_none
> state = self._state_constructor(instance, self)
>   File 
> "C:\Users\vToMy\PycharmProjects\sqlalchemy\lib\sqlalchemy\util\langhelpers.py",
>  
> line 754, in __get__
> obj.__dict__[self.__name__] = result = self.fget(obj)
>   File 
> "C:\Users\vToMy\PycharmProjects\sqlalchemy\lib\sqlalchemy\orm\instrumentation.py",
>  
> line 177, in _state_constructor
> self.dispatch.first_init(self, self.class_)
>   File 
> "C:\Users\vToMy\PycharmProjects\sqlalchemy\lib\sqlalchemy\event\attr.py", 
> line 256, in __call__
> fn(*args, **kw)
>   File 
> "C:\Users\vToMy\PycharmProjects\sqlalchemy\lib\sqlalchemy\orm\mapper.py", 
> line 2943, in _event_on_first_init
> configure_mappers()
>   File 
> "C:\Users\vToMy\PycharmProjects\sqlalchemy\lib\sqlalchemy\orm\mapper.py", 
> line 2822, in configure_mappers
> Mapper.dispatch._for_class(Mapper).before_configured()
>   File 
> "C:\Users\vToMy\PycharmProjects\sqlalchemy\lib\sqlalchemy\event\attr.py", 
> line 217, in __call__
> for fn in self.parent_listeners:
> RuntimeError: deque mutated during iteration
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.