mirror of
https://github.com/zulip/zulip.git
synced 2025-11-10 00:46:03 +00:00
Annotate zerver/lib/sqlalchemy_utils.py.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from django.db import connection
|
||||
from zerver.lib.db import TimeTrackingConnection
|
||||
|
||||
import sqlalchemy
|
||||
|
||||
@@ -6,12 +7,15 @@ import sqlalchemy
|
||||
# existing Django database connections.
|
||||
class NonClosingPool(sqlalchemy.pool.NullPool):
|
||||
def status(self):
|
||||
# type: () -> str
|
||||
return "NonClosingPool"
|
||||
|
||||
def _do_return_conn(self, conn):
|
||||
# type: (sqlalchemy.engine.base.Connection) -> None
|
||||
pass
|
||||
|
||||
def recreate(self):
|
||||
# type: () -> NonClosingPool
|
||||
return self.__class__(creator=self._creator, # type: ignore # __class__
|
||||
recycle=self._recycle,
|
||||
use_threadlocal=self._use_threadlocal,
|
||||
@@ -22,9 +26,11 @@ class NonClosingPool(sqlalchemy.pool.NullPool):
|
||||
|
||||
sqlalchemy_engine = None
|
||||
def get_sqlalchemy_connection():
|
||||
# type: () -> sqlalchemy.engine.base.Connection
|
||||
global sqlalchemy_engine
|
||||
if sqlalchemy_engine is None:
|
||||
def get_dj_conn():
|
||||
# type: () -> TimeTrackingConnection
|
||||
connection.ensure_connection()
|
||||
return connection.connection
|
||||
sqlalchemy_engine = sqlalchemy.create_engine('postgresql://',
|
||||
|
||||
Reference in New Issue
Block a user