Changeset View
Changeset View
Standalone View
Standalone View
swh/core/db/__init__.py
Show First 20 Lines • Show All 289 Lines • ▼ Show 20 Lines | ) -> None: | ||||
# transaction. | # transaction. | ||||
write_thread.join() | write_thread.join() | ||||
if exc_info: | if exc_info: | ||||
# postgresql returned an error, let's raise it. | # postgresql returned an error, let's raise it. | ||||
raise exc_info[1].with_traceback(exc_info[2]) | raise exc_info[1].with_traceback(exc_info[2]) | ||||
def mktemp(self, tblname: str, cur: Optional[psycopg2.extensions.cursor] = None): | def mktemp(self, tblname: str, cur: Optional[psycopg2.extensions.cursor] = None): | ||||
self.cursor(cur).execute("SELECT swh_mktemp(%s)", (tblname,)) | self.cursor(cur).execute("SELECT swh_mktemp(%s)", (tblname,)) | ||||
def get_current_version(self): | |||||
"""Return the database version stored in the backend. This should match the | |||||
current_version attribute of the backend implementation class. | |||||
""" | |||||
with self.transaction() as cur: | |||||
cur.execute("select version from dbversion order by dbversion desc limit 1") | |||||
res = cur.fetchone() | |||||
assert res is not None | |||||
return res[0] |