Compare commits
12 commits
76b60e5556
...
6b8fb3b470
| Author | SHA1 | Date | |
|---|---|---|---|
| 6b8fb3b470 | |||
| 50ae94c9e9 | |||
|
|
ce9d1815e1 | ||
| 7ecc8f776d | |||
|
|
83123688ee | ||
| 3e4e9676cf | |||
| 33e5d91d7d | |||
| ccf5da9af9 | |||
| 9b5a9afa65 | |||
| 5cf88056e7 | |||
| 5e3919406d | |||
| ae37c342d8 |
12 changed files with 445 additions and 6 deletions
49
i18n/be/LC_MESSAGES/messages.po
Normal file
49
i18n/be/LC_MESSAGES/messages.po
Normal file
|
|
@ -0,0 +1,49 @@
|
||||||
|
# Translations template for PROJECT.
|
||||||
|
# Copyright (C) 2026 ORGANIZATION
|
||||||
|
# This file is distributed under the same license as the PROJECT project.
|
||||||
|
# FIRST AUTHOR <EMAIL@ADDRESS>, 2026.
|
||||||
|
#
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: PROJECT VERSION\n"
|
||||||
|
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
|
||||||
|
"POT-Creation-Date: 2026-03-07 17:05+0000\n"
|
||||||
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
|
"Last-Translator: Automatically generated\n"
|
||||||
|
"Language-Team: none\n"
|
||||||
|
"Language: be\n"
|
||||||
|
"MIME-Version: 1.0\n"
|
||||||
|
"Content-Type: text/plain; charset=utf-8\n"
|
||||||
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && "
|
||||||
|
"n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n"
|
||||||
|
"Generated-By: Babel 2.17.0\n"
|
||||||
|
|
||||||
|
#: src/snapshots/templates/article-template.html.j2:66
|
||||||
|
msgid "How do I know that I can trust this page?"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/snapshots/templates/article-template.html.j2:73
|
||||||
|
msgid ""
|
||||||
|
"This story is a copy of an article from <a href=\"{site_url}\" class"
|
||||||
|
"=\"snap-trust-header__sitelink\">{site_title}</a>. It is delivered to "
|
||||||
|
"you from a trusted archive to assure its availability over time."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/snapshots/templates/article-template.html.j2:76
|
||||||
|
msgid "View the article source"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/snapshots/templates/article-template.html.j2:143
|
||||||
|
msgid "You are leaving this page"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/snapshots/templates/article-template.html.j2:163
|
||||||
|
msgid ""
|
||||||
|
"This link will redirect you to an external website. If it’s not available"
|
||||||
|
" in your region, you may not be able to access it."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/snapshots/templates/article-template.html.j2:165
|
||||||
|
msgid "Continue"
|
||||||
|
msgstr ""
|
||||||
|
|
@ -24,12 +24,12 @@ msgstr "How do I know that I can trust this page?"
|
||||||
|
|
||||||
#: src/snapshots/templates/article-template.html.j2:73
|
#: src/snapshots/templates/article-template.html.j2:73
|
||||||
msgid ""
|
msgid ""
|
||||||
"This story is a copy of an article from <a href=\"%(site_url)\" class"
|
"This story is a copy of an article from <a href=\"{site_url}\" class"
|
||||||
"=\"snap-trust-header__sitelink\">%(site_title)</a>. It is delivered to "
|
"=\"snap-trust-header__sitelink\">{site_title}</a>. It is delivered to "
|
||||||
"you from a trusted archive to assure its availability over time."
|
"you from a trusted archive to assure its availability over time."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"This story is a copy of an article from <a href=\"%(site_url)\" class"
|
"This story is a copy of an article from <a href=\"{site_url}\" class"
|
||||||
"=\"snap-trust-header__sitelink\">%(site_title)</a>. It is delivered to "
|
"=\"snap-trust-header__sitelink\">{site_title}</a>. It is delivered to "
|
||||||
"you from a trusted archive to assure its availability over time."
|
"you from a trusted archive to assure its availability over time."
|
||||||
|
|
||||||
#: src/snapshots/templates/article-template.html.j2:76
|
#: src/snapshots/templates/article-template.html.j2:76
|
||||||
|
|
|
||||||
56
i18n/es/LC_MESSAGES/messages.po
Normal file
56
i18n/es/LC_MESSAGES/messages.po
Normal file
|
|
@ -0,0 +1,56 @@
|
||||||
|
# Translations template for PROJECT.
|
||||||
|
# Copyright (C) 2026 ORGANIZATION
|
||||||
|
# This file is distributed under the same license as the PROJECT project.
|
||||||
|
# FIRST AUTHOR <EMAIL@ADDRESS>, 2026.
|
||||||
|
#
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: PROJECT VERSION\n"
|
||||||
|
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
|
||||||
|
"POT-Creation-Date: 2026-03-07 17:05+0000\n"
|
||||||
|
"PO-Revision-Date: 2026-03-08 15:54+0000\n"
|
||||||
|
"Last-Translator: irl <irl@sr2.uk>\n"
|
||||||
|
"Language-Team: Spanish <https://hosted.weblate.org/projects/sr2/snapdirect/"
|
||||||
|
"es/>\n"
|
||||||
|
"Language: es\n"
|
||||||
|
"MIME-Version: 1.0\n"
|
||||||
|
"Content-Type: text/plain; charset=utf-8\n"
|
||||||
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
||||||
|
"X-Generator: Weblate 5.17-dev\n"
|
||||||
|
"Generated-By: Babel 2.17.0\n"
|
||||||
|
|
||||||
|
#: src/snapshots/templates/article-template.html.j2:66
|
||||||
|
msgid "How do I know that I can trust this page?"
|
||||||
|
msgstr "¿Cómo sé que puedo confiar en esta página?"
|
||||||
|
|
||||||
|
#: src/snapshots/templates/article-template.html.j2:73
|
||||||
|
msgid ""
|
||||||
|
"This story is a copy of an article from <a href=\"{site_url}\" class"
|
||||||
|
"=\"snap-trust-header__sitelink\">{site_title}</a>. It is delivered to "
|
||||||
|
"you from a trusted archive to assure its availability over time."
|
||||||
|
msgstr ""
|
||||||
|
"Esta historia es una copia de un artículo de <a href=\"{site_url}\" "
|
||||||
|
"class=\"snap-trust-header__sitelink\">{site_title}</a>. Se la entregamos "
|
||||||
|
"desde un archivo confiable para garantizar su disponibilidad a lo largo del "
|
||||||
|
"tiempo."
|
||||||
|
|
||||||
|
#: src/snapshots/templates/article-template.html.j2:76
|
||||||
|
msgid "View the article source"
|
||||||
|
msgstr "Ver el código fuente del artículo"
|
||||||
|
|
||||||
|
#: src/snapshots/templates/article-template.html.j2:143
|
||||||
|
msgid "You are leaving this page"
|
||||||
|
msgstr "Estas abandonando esta pagina"
|
||||||
|
|
||||||
|
#: src/snapshots/templates/article-template.html.j2:163
|
||||||
|
msgid ""
|
||||||
|
"This link will redirect you to an external website. If it’s not available"
|
||||||
|
" in your region, you may not be able to access it."
|
||||||
|
msgstr ""
|
||||||
|
"Este enlace te redirigirá a un sitio web externo. Si no está disponible en "
|
||||||
|
"tu región, es posible que no lo puedas acceder."
|
||||||
|
|
||||||
|
#: src/snapshots/templates/article-template.html.j2:165
|
||||||
|
msgid "Continue"
|
||||||
|
msgstr "Continuar"
|
||||||
48
i18n/fa/LC_MESSAGES/messages.po
Normal file
48
i18n/fa/LC_MESSAGES/messages.po
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
# Translations template for PROJECT.
|
||||||
|
# Copyright (C) 2026 ORGANIZATION
|
||||||
|
# This file is distributed under the same license as the PROJECT project.
|
||||||
|
# FIRST AUTHOR <EMAIL@ADDRESS>, 2026.
|
||||||
|
#
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: PROJECT VERSION\n"
|
||||||
|
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
|
||||||
|
"POT-Creation-Date: 2026-03-07 17:05+0000\n"
|
||||||
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
|
"Last-Translator: Automatically generated\n"
|
||||||
|
"Language-Team: none\n"
|
||||||
|
"Language: fa\n"
|
||||||
|
"MIME-Version: 1.0\n"
|
||||||
|
"Content-Type: text/plain; charset=utf-8\n"
|
||||||
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
"Plural-Forms: nplurals=2; plural=n > 1;\n"
|
||||||
|
"Generated-By: Babel 2.17.0\n"
|
||||||
|
|
||||||
|
#: src/snapshots/templates/article-template.html.j2:66
|
||||||
|
msgid "How do I know that I can trust this page?"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/snapshots/templates/article-template.html.j2:73
|
||||||
|
msgid ""
|
||||||
|
"This story is a copy of an article from <a href=\"{site_url}\" class"
|
||||||
|
"=\"snap-trust-header__sitelink\">{site_title}</a>. It is delivered to "
|
||||||
|
"you from a trusted archive to assure its availability over time."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/snapshots/templates/article-template.html.j2:76
|
||||||
|
msgid "View the article source"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/snapshots/templates/article-template.html.j2:143
|
||||||
|
msgid "You are leaving this page"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/snapshots/templates/article-template.html.j2:163
|
||||||
|
msgid ""
|
||||||
|
"This link will redirect you to an external website. If it’s not available"
|
||||||
|
" in your region, you may not be able to access it."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/snapshots/templates/article-template.html.j2:165
|
||||||
|
msgid "Continue"
|
||||||
|
msgstr ""
|
||||||
48
i18n/ka/LC_MESSAGES/messages.po
Normal file
48
i18n/ka/LC_MESSAGES/messages.po
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
# Translations template for PROJECT.
|
||||||
|
# Copyright (C) 2026 ORGANIZATION
|
||||||
|
# This file is distributed under the same license as the PROJECT project.
|
||||||
|
# FIRST AUTHOR <EMAIL@ADDRESS>, 2026.
|
||||||
|
#
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: PROJECT VERSION\n"
|
||||||
|
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
|
||||||
|
"POT-Creation-Date: 2026-03-07 17:05+0000\n"
|
||||||
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
|
"Last-Translator: Automatically generated\n"
|
||||||
|
"Language-Team: none\n"
|
||||||
|
"Language: ka\n"
|
||||||
|
"MIME-Version: 1.0\n"
|
||||||
|
"Content-Type: text/plain; charset=utf-8\n"
|
||||||
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
||||||
|
"Generated-By: Babel 2.17.0\n"
|
||||||
|
|
||||||
|
#: src/snapshots/templates/article-template.html.j2:66
|
||||||
|
msgid "How do I know that I can trust this page?"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/snapshots/templates/article-template.html.j2:73
|
||||||
|
msgid ""
|
||||||
|
"This story is a copy of an article from <a href=\"{site_url}\" class"
|
||||||
|
"=\"snap-trust-header__sitelink\">{site_title}</a>. It is delivered to "
|
||||||
|
"you from a trusted archive to assure its availability over time."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/snapshots/templates/article-template.html.j2:76
|
||||||
|
msgid "View the article source"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/snapshots/templates/article-template.html.j2:143
|
||||||
|
msgid "You are leaving this page"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/snapshots/templates/article-template.html.j2:163
|
||||||
|
msgid ""
|
||||||
|
"This link will redirect you to an external website. If it’s not available"
|
||||||
|
" in your region, you may not be able to access it."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/snapshots/templates/article-template.html.j2:165
|
||||||
|
msgid "Continue"
|
||||||
|
msgstr ""
|
||||||
|
|
@ -23,8 +23,8 @@ msgstr ""
|
||||||
|
|
||||||
#: src/snapshots/templates/article-template.html.j2:73
|
#: src/snapshots/templates/article-template.html.j2:73
|
||||||
msgid ""
|
msgid ""
|
||||||
"This story is a copy of an article from <a href=\"%(site_url)\" class"
|
"This story is a copy of an article from <a href=\"{site_url}\" class"
|
||||||
"=\"snap-trust-header__sitelink\">%(site_title)</a>. It is delivered to "
|
"=\"snap-trust-header__sitelink\">{site_title}</a>. It is delivered to "
|
||||||
"you from a trusted archive to assure its availability over time."
|
"you from a trusted archive to assure its availability over time."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
|
|
||||||
48
i18n/prs/LC_MESSAGES/messages.po
Normal file
48
i18n/prs/LC_MESSAGES/messages.po
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
# Translations template for PROJECT.
|
||||||
|
# Copyright (C) 2026 ORGANIZATION
|
||||||
|
# This file is distributed under the same license as the PROJECT project.
|
||||||
|
# FIRST AUTHOR <EMAIL@ADDRESS>, 2026.
|
||||||
|
#
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: PROJECT VERSION\n"
|
||||||
|
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
|
||||||
|
"POT-Creation-Date: 2026-03-07 17:05+0000\n"
|
||||||
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
|
"Last-Translator: Automatically generated\n"
|
||||||
|
"Language-Team: none\n"
|
||||||
|
"Language: prs\n"
|
||||||
|
"MIME-Version: 1.0\n"
|
||||||
|
"Content-Type: text/plain; charset=utf-8\n"
|
||||||
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
||||||
|
"Generated-By: Babel 2.17.0\n"
|
||||||
|
|
||||||
|
#: src/snapshots/templates/article-template.html.j2:66
|
||||||
|
msgid "How do I know that I can trust this page?"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/snapshots/templates/article-template.html.j2:73
|
||||||
|
msgid ""
|
||||||
|
"This story is a copy of an article from <a href=\"{site_url}\" class"
|
||||||
|
"=\"snap-trust-header__sitelink\">{site_title}</a>. It is delivered to "
|
||||||
|
"you from a trusted archive to assure its availability over time."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/snapshots/templates/article-template.html.j2:76
|
||||||
|
msgid "View the article source"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/snapshots/templates/article-template.html.j2:143
|
||||||
|
msgid "You are leaving this page"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/snapshots/templates/article-template.html.j2:163
|
||||||
|
msgid ""
|
||||||
|
"This link will redirect you to an external website. If it’s not available"
|
||||||
|
" in your region, you may not be able to access it."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/snapshots/templates/article-template.html.j2:165
|
||||||
|
msgid "Continue"
|
||||||
|
msgstr ""
|
||||||
48
i18n/ps/LC_MESSAGES/messages.po
Normal file
48
i18n/ps/LC_MESSAGES/messages.po
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
# Translations template for PROJECT.
|
||||||
|
# Copyright (C) 2026 ORGANIZATION
|
||||||
|
# This file is distributed under the same license as the PROJECT project.
|
||||||
|
# FIRST AUTHOR <EMAIL@ADDRESS>, 2026.
|
||||||
|
#
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: PROJECT VERSION\n"
|
||||||
|
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
|
||||||
|
"POT-Creation-Date: 2026-03-07 17:05+0000\n"
|
||||||
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
|
"Last-Translator: Automatically generated\n"
|
||||||
|
"Language-Team: none\n"
|
||||||
|
"Language: ps\n"
|
||||||
|
"MIME-Version: 1.0\n"
|
||||||
|
"Content-Type: text/plain; charset=utf-8\n"
|
||||||
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
||||||
|
"Generated-By: Babel 2.17.0\n"
|
||||||
|
|
||||||
|
#: src/snapshots/templates/article-template.html.j2:66
|
||||||
|
msgid "How do I know that I can trust this page?"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/snapshots/templates/article-template.html.j2:73
|
||||||
|
msgid ""
|
||||||
|
"This story is a copy of an article from <a href=\"{site_url}\" class"
|
||||||
|
"=\"snap-trust-header__sitelink\">{site_title}</a>. It is delivered to "
|
||||||
|
"you from a trusted archive to assure its availability over time."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/snapshots/templates/article-template.html.j2:76
|
||||||
|
msgid "View the article source"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/snapshots/templates/article-template.html.j2:143
|
||||||
|
msgid "You are leaving this page"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/snapshots/templates/article-template.html.j2:163
|
||||||
|
msgid ""
|
||||||
|
"This link will redirect you to an external website. If it’s not available"
|
||||||
|
" in your region, you may not be able to access it."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/snapshots/templates/article-template.html.j2:165
|
||||||
|
msgid "Continue"
|
||||||
|
msgstr ""
|
||||||
49
i18n/ru/LC_MESSAGES/messages.po
Normal file
49
i18n/ru/LC_MESSAGES/messages.po
Normal file
|
|
@ -0,0 +1,49 @@
|
||||||
|
# Translations template for PROJECT.
|
||||||
|
# Copyright (C) 2026 ORGANIZATION
|
||||||
|
# This file is distributed under the same license as the PROJECT project.
|
||||||
|
# FIRST AUTHOR <EMAIL@ADDRESS>, 2026.
|
||||||
|
#
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: PROJECT VERSION\n"
|
||||||
|
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
|
||||||
|
"POT-Creation-Date: 2026-03-07 17:05+0000\n"
|
||||||
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
|
"Last-Translator: Automatically generated\n"
|
||||||
|
"Language-Team: none\n"
|
||||||
|
"Language: ru\n"
|
||||||
|
"MIME-Version: 1.0\n"
|
||||||
|
"Content-Type: text/plain; charset=utf-8\n"
|
||||||
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && "
|
||||||
|
"n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n"
|
||||||
|
"Generated-By: Babel 2.17.0\n"
|
||||||
|
|
||||||
|
#: src/snapshots/templates/article-template.html.j2:66
|
||||||
|
msgid "How do I know that I can trust this page?"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/snapshots/templates/article-template.html.j2:73
|
||||||
|
msgid ""
|
||||||
|
"This story is a copy of an article from <a href=\"{site_url}\" class"
|
||||||
|
"=\"snap-trust-header__sitelink\">{site_title}</a>. It is delivered to "
|
||||||
|
"you from a trusted archive to assure its availability over time."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/snapshots/templates/article-template.html.j2:76
|
||||||
|
msgid "View the article source"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/snapshots/templates/article-template.html.j2:143
|
||||||
|
msgid "You are leaving this page"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/snapshots/templates/article-template.html.j2:163
|
||||||
|
msgid ""
|
||||||
|
"This link will redirect you to an external website. If it’s not available"
|
||||||
|
" in your region, you may not be able to access it."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/snapshots/templates/article-template.html.j2:165
|
||||||
|
msgid "Continue"
|
||||||
|
msgstr ""
|
||||||
50
src/database.py
Normal file
50
src/database.py
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
import contextlib
|
||||||
|
from typing import Annotated, Iterator, Generator
|
||||||
|
|
||||||
|
from fastapi import Depends
|
||||||
|
from sqlalchemy import (
|
||||||
|
MetaData, create_engine, Connection,
|
||||||
|
)
|
||||||
|
from sqlalchemy.orm import sessionmaker, Session
|
||||||
|
|
||||||
|
from src.config import settings
|
||||||
|
from src.constants import DB_NAMING_CONVENTION
|
||||||
|
|
||||||
|
engine = create_engine(
|
||||||
|
str(settings.DATABASE_URL),
|
||||||
|
pool_size=settings.DATABASE_POOL_SIZE,
|
||||||
|
pool_recycle=settings.DATABASE_POOL_TTL,
|
||||||
|
pool_pre_ping=settings.DATABASE_POOL_PRE_PING,
|
||||||
|
)
|
||||||
|
metadata = MetaData(naming_convention=DB_NAMING_CONVENTION)
|
||||||
|
sm = sessionmaker(autocommit=False, expire_on_commit=False, bind=engine)
|
||||||
|
|
||||||
|
|
||||||
|
@contextlib.contextmanager
|
||||||
|
def get_db_connection() -> Iterator[Connection]:
|
||||||
|
with engine.connect() as connection:
|
||||||
|
try:
|
||||||
|
yield connection
|
||||||
|
except Exception:
|
||||||
|
connection.rollback()
|
||||||
|
raise
|
||||||
|
|
||||||
|
|
||||||
|
@contextlib.contextmanager
|
||||||
|
def get_db_session() -> Iterator[Session]:
|
||||||
|
session = sm()
|
||||||
|
try:
|
||||||
|
yield session
|
||||||
|
except Exception:
|
||||||
|
session.rollback()
|
||||||
|
raise
|
||||||
|
finally:
|
||||||
|
session.close()
|
||||||
|
|
||||||
|
|
||||||
|
def get_db() -> Generator[Session, None]:
|
||||||
|
with get_db_session() as session:
|
||||||
|
yield session
|
||||||
|
|
||||||
|
|
||||||
|
DbSession = Annotated[Session, Depends(get_db)]
|
||||||
34
src/models.py
Normal file
34
src/models.py
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
from datetime import datetime
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
from sqlalchemy import DateTime, JSON, func
|
||||||
|
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column
|
||||||
|
from src.database import metadata
|
||||||
|
|
||||||
|
|
||||||
|
class CustomBase(DeclarativeBase):
|
||||||
|
type_annotation_map = {
|
||||||
|
datetime: DateTime(timezone=True),
|
||||||
|
dict[str, Any]: JSON,
|
||||||
|
}
|
||||||
|
metadata = metadata
|
||||||
|
|
||||||
|
class ActivatedMixin:
|
||||||
|
active: Mapped[bool] = mapped_column(default=True)
|
||||||
|
|
||||||
|
|
||||||
|
class DeletedTimestampMixin:
|
||||||
|
deleted_at: Mapped[datetime | None] = mapped_column(nullable=True)
|
||||||
|
|
||||||
|
|
||||||
|
class DescriptionMixin:
|
||||||
|
description: Mapped[str]
|
||||||
|
|
||||||
|
|
||||||
|
class IdMixin:
|
||||||
|
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
|
||||||
|
|
||||||
|
|
||||||
|
class TimestampMixin:
|
||||||
|
created_at: Mapped[datetime] = mapped_column(default=func.now())
|
||||||
|
updated_at: Mapped[datetime] = mapped_column(default=func.now(), onupdate=func.now())
|
||||||
9
src/snapshots/models.py
Normal file
9
src/snapshots/models.py
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
from sqlalchemy.orm import Mapped
|
||||||
|
|
||||||
|
from src.models import CustomBase, IdMixin
|
||||||
|
|
||||||
|
|
||||||
|
class Snapshot(CustomBase, IdMixin):
|
||||||
|
__tablename__ = "snapshot"
|
||||||
|
|
||||||
|
url: Mapped[str]
|
||||||
Loading…
Add table
Add a link
Reference in a new issue