You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
### Session-level vs. Engine level transaction control
28
+
29
+
Just copied from the [official documentation](https://docs.sqlalchemy.org/en/20/orm/session_transaction.html#session-level-vs-engine-level-transaction-control):
Use the [event lister to refresh volatile authentication credentials](https://docs.sqlalchemy.org/en/20/core/engines.html#generating-dynamic-authentication-tokens).
85
+
86
+
Event Hooks:
87
+
88
+
*`checkout` Event: Triggered when a connection is checked out from the pool. Useful for tasks like setting session-level parameters. each `engine.connect()` will trigger this event.
89
+
*`checkin` Event: Triggered when a connection is returned to the pool (reverse operation of `checkout`). Can be used for cleanup tasks.
90
+
*`connect` Event:
91
+
Type: Notification Event
92
+
Purpose: Triggered after a new DBAPI connection has been established.
93
+
Usage: Primarily used for performing actions post-connection, such as setting session-level parameters, initializing database schemas, or logging connection details. First `engine.connect()` (not the subsequent) will trigger this event.
94
+
*`do_connect` Event:
95
+
Type: Customization Hook
96
+
Purpose: Allows developers to override or customize the actual process of establishing a new DBAPI connection.
97
+
Usage: Useful when you need to implement custom connection logic, integrate with non-standard DBAPI drivers, or modify connection parameters dynamically. First `engine.connect()` (not the subsequent) will trigger this event.
98
+
`do_connect` event is triggered before the `connect` event.
Some vendor specific SQL servers ([Snowflake for .e.g](https://github.com/snowflakedb/snowflake-sqlalchemy/issues/550)) implementations some kind of keep-live heartbeat mechanism to keep the connection alive. Which means once the user is logged in, the connection (user session) will be kept alive until the user logs out even the token is expired. User don't need to send small query to keep alive, as the keep-alive signals are sent in background by the vendor specific module implicitly. This is useful for long running applications.
@@ -48,8 +128,8 @@ from sqlalchemy.orm import mapped_column
48
128
The [mapped_column()](https://docs.sqlalchemy.org/en/20/orm/mapping_api.html#sqlalchemy.orm.mapped_column) can have type annotations within a special SQLAlchemy type called [Mapped](https://docs.sqlalchemy.org/en/20/orm/internals.html#sqlalchemy.orm.Mapped).
49
129
For e.g.:
50
130
51
-
-`fullname: Mapped[str]` is compiled to SQL: `fullname VARCHAR NOT NULL`
52
-
-`fullname: Mapped[Optional[str]]` is compiled to SQL: `fullname VARCHAR`
131
+
*`fullname: Mapped[str]` is compiled to SQL: `fullname VARCHAR NOT NULL`
132
+
*`fullname: Mapped[Optional[str]]` is compiled to SQL: `fullname VARCHAR`
53
133
54
134
[Default type map](https://docs.sqlalchemy.org/en/20/orm/declarative_tables.html#mapped-column-derives-the-datatype-and-nullability-from-the-mapped-annotation) ():
Use the [event lister to refresh volatile authentication credentials](https://docs.sqlalchemy.org/en/14/core/engines.html#generating-dynamic-authentication-tokens).
87
-
88
-
Event Hooks:
89
-
90
-
-`checkout` Event: Triggered when a connection is checked out from the pool. Useful for tasks like setting session-level parameters. each `engine.connect()` will trigger this event.
91
-
-`checkin` Event: Triggered when a connection is returned to the pool (reverse operation of `checkout`). Can be used for cleanup tasks.
92
-
-`connect` Event:
93
-
Type: Notification Event
94
-
Purpose: Triggered after a new DBAPI connection has been established.
95
-
Usage: Primarily used for performing actions post-connection, such as setting session-level parameters, initializing database schemas, or logging connection details. First `engine.connect()` (not the subsequent) will trigger this event.
96
-
-`do_connect` Event:
97
-
Type: Customization Hook
98
-
Purpose: Allows developers to override or customize the actual process of establishing a new DBAPI connection.
99
-
Usage: Useful when you need to implement custom connection logic, integrate with non-standard DBAPI drivers, or modify connection parameters dynamically. First `engine.connect()` (not the subsequent) will trigger this event.
100
-
`do_connect` event is triggered before the `connect` event.
Some vendor specific SQL servers ([Snowflake for .e.g](https://github.com/snowflakedb/snowflake-sqlalchemy/issues/550)) implementations some kind of keep-live heartbeat mechanism to keep the connection alive. Which means once the user is logged in, the connection (user session) will be kept alive until the user logs out even the token is expired. User don't need to send small query to keep alive, as the keep-alive signals are sent in background by the vendor specific module implicitly. This is useful for long running applications.
0 commit comments