diff options
author | David Robertson <davidr@element.io> | 2022-09-26 18:28:32 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-26 18:28:32 +0100 |
commit | 0a38c7ec6d46b6e51bfa53ff44e51637d3c63f5c (patch) | |
tree | 3509b9f8af1050186338a6f06f15e76f87562f89 /synapse/storage/engines/postgres.py | |
parent | typing: check origin server of typing event against room's servers (#13830) (diff) | |
download | synapse-0a38c7ec6d46b6e51bfa53ff44e51637d3c63f5c.tar.xz |
Snapshot schema 72 (#13873)
Including another batch of fixes to the schema dump script
Diffstat (limited to 'synapse/storage/engines/postgres.py')
-rw-r--r-- | synapse/storage/engines/postgres.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/synapse/storage/engines/postgres.py b/synapse/storage/engines/postgres.py index 7f7d006ac2..d8c0f64d9a 100644 --- a/synapse/storage/engines/postgres.py +++ b/synapse/storage/engines/postgres.py @@ -31,7 +31,9 @@ if TYPE_CHECKING: logger = logging.getLogger(__name__) -class PostgresEngine(BaseDatabaseEngine[psycopg2.extensions.connection]): +class PostgresEngine( + BaseDatabaseEngine[psycopg2.extensions.connection, psycopg2.extensions.cursor] +): def __init__(self, database_config: Mapping[str, Any]): super().__init__(psycopg2, database_config) psycopg2.extensions.register_type(psycopg2.extensions.UNICODE) @@ -212,3 +214,11 @@ class PostgresEngine(BaseDatabaseEngine[psycopg2.extensions.connection]): else: isolation_level = self.isolation_level_map[isolation_level] return conn.set_isolation_level(isolation_level) + + @staticmethod + def executescript(cursor: psycopg2.extensions.cursor, script: str) -> None: + """Execute a chunk of SQL containing multiple semicolon-delimited statements. + + Psycopg2 seems happy to do this in DBAPI2's `execute()` function. + """ + cursor.execute(script) |