Re: [sqlalchemy] Logging handler logic

2021-06-13 Thread Mike Bayer
the line you refer towards involves a flag called "echo", which is described at 
https://docs.sqlalchemy.org/en/14/core/engines.html#more-on-the-echo-flag and 
is entirely optional.  if you don't use the echo flag, SQLAlchemy's logging 
behavior is completely traditional, with the caveat that the Engine, Connection 
and Pool objects will check the level of loggers before opting to send out 
logging.info() and logging.debug() calls as there is some additional formatting 
expense for some of these calls.

I'm not familiar with what you mean by "IO emitted to the console streams 
breaks calling code", SQLAlchemy doesn't emit any IO that it isn't instructed 
to nor does it set up any handlers if you aren't using the "echo" flag.




On Sun, Jun 13, 2021, at 1:14 PM, jca...@gmail.com  
wrote:
> Hello everyone,
> After reviewing the handler logic, I am not clear that it implements logging
> within the pattern guidelines defined by the base logging implementation.
> 
> In log.py#L103 
> ,
>  the level and existence of at least one handler are checked.
> 
> I only have a handler added to a root logger that I don't control, and we rely
> on ancestral propagation.
> 
> The concern I have is due to any IO emitted to the console streams breaks
> the calling code that I don't control. With this pattern, I have to 
> preemptively
> add null handlers to every logger, and if I miss one and it manifests in 
> production,
> I'll have a problem.
> 
> Anyone have any thoughts around this?
> 
> Thanks,
> jlc
> 
> 
> 

> -- 
> SQLAlchemy - 
> The Python SQL Toolkit and Object Relational Mapper
>  
> http://www.sqlalchemy.org/
>  
> To post example code, please provide an MCVE: Minimal, Complete, and 
> Verifiable Example. See http://stackoverflow.com/help/mcve for a full 
> description.
> --- 
> 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 view this discussion on the web visit 
> https://groups.google.com/d/msgid/sqlalchemy/80cade67-c6ed-41a7-a1a2-ba1fdb36b8aen%40googlegroups.com
>  
> .

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/2b71ae26-ce1c-454c-bf84-ddd022d490e3%40www.fastmail.com.


Re: [sqlalchemy] No NOWAIT for FOR UPDATE

2021-06-13 Thread Mike Bayer
hi 

you need to compile with the postgresql dialect, see 
https://docs.sqlalchemy.org/en/14/faq/sqlexpressions.html#stringifying-for-specific-databases

from sqlalchemy import column
from sqlalchemy import table
from sqlalchemy.dialects import postgresql
from sqlalchemy.future import select

t = table("internal", column("person_id_internal"))

sql = select(
t.c.person_id_internal
).with_for_update(nowait=True)
print(sql.compile(dialect=postgresql.dialect()))


On Sun, Jun 13, 2021, at 12:23 PM, sector119 wrote:
> Hello!
> 
> On a PostgreSQL database can't get NOWAIT with FOR UPDATE clause (
> 
> sqlalchemy 1.4.18
> 
> from sqlalchemy.future import select
> from unity.models.unity import Internal
> 
> sql = select(
> Internal.person_id_internal
> ).with_for_update(nowait=True)
> 
> str(sql)
> Out[12]: 'SELECT unity.internals.person_id_internal \nFROM unity.internals 
> FOR UPDATE'
> 

> -- 
> SQLAlchemy - 
> The Python SQL Toolkit and Object Relational Mapper
>  
> http://www.sqlalchemy.org/
>  
> To post example code, please provide an MCVE: Minimal, Complete, and 
> Verifiable Example. See http://stackoverflow.com/help/mcve for a full 
> description.
> --- 
> 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 view this discussion on the web visit 
> https://groups.google.com/d/msgid/sqlalchemy/587b5317-e275-4c22-a78e-460eeafff1c1n%40googlegroups.com
>  
> .

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/391054ea-1ade-429b-ad41-100390cd935b%40www.fastmail.com.


[sqlalchemy] Logging handler logic

2021-06-13 Thread jca...@gmail.com
Hello everyone,
After reviewing the handler logic, I am not clear that it implements logging
within the pattern guidelines defined by the base logging implementation.

In log.py#L103 
,
 
the level and existence of at least one handler are checked.

I only have a handler added to a root logger that I don't control, and we 
rely
on ancestral propagation.

The concern I have is due to any IO emitted to the console streams breaks
the calling code that I don't control. With this pattern, I have to 
preemptively
add null handlers to every logger, and if I miss one and it manifests in 
production,
I'll have a problem.

Anyone have any thoughts around this?

Thanks,
jlc


-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/80cade67-c6ed-41a7-a1a2-ba1fdb36b8aen%40googlegroups.com.


[sqlalchemy] No NOWAIT for FOR UPDATE

2021-06-13 Thread sector119
Hello!

On a PostgreSQL database can't get NOWAIT with FOR UPDATE clause (

sqlalchemy 1.4.18

from sqlalchemy.future import select
from unity.models.unity import Internal

sql = select(
Internal.person_id_internal
).with_for_update(nowait=True)

str(sql)
Out[12]: 'SELECT unity.internals.person_id_internal \nFROM unity.internals 
FOR UPDATE'

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/587b5317-e275-4c22-a78e-460eeafff1c1n%40googlegroups.com.