Mercurial > libervia-backend
comparison sat/memory/sqla.py @ 3893:045af0eeda3f
core, CLI (base), tools (common/data_format): typing/core readability
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 21 Sep 2022 22:20:43 +0200 |
parents | 100dd30244c6 |
children | 1a77e1f866f9 |
comparison
equal
deleted
inserted
replaced
3892:ba78cc0c8d59 | 3893:045af0eeda3f |
---|---|
14 # GNU Affero General Public License for more details. | 14 # GNU Affero General Public License for more details. |
15 | 15 |
16 # You should have received a copy of the GNU Affero General Public License | 16 # You should have received a copy of the GNU Affero General Public License |
17 # along with this program. If not, see <http://www.gnu.org/licenses/>. | 17 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
18 | 18 |
19 import asyncio | |
20 from asyncio.subprocess import PIPE | |
21 import copy | |
22 from datetime import datetime | |
23 from pathlib import Path | |
19 import sys | 24 import sys |
20 import time | 25 import time |
21 import asyncio | 26 from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple, Union |
22 import copy | 27 |
23 from datetime import datetime | 28 from alembic import config as al_config, script as al_script |
24 from asyncio.subprocess import PIPE | 29 from alembic.runtime import migration as al_migration |
25 from pathlib import Path | 30 from sqlalchemy import and_, delete, event, func, or_, update |
26 from typing import Union, Dict, List, Tuple, Iterable, Any, Callable, Optional | 31 from sqlalchemy import Integer, literal_column, text |
27 from sqlalchemy.ext.asyncio import AsyncSession, AsyncEngine, create_async_engine | 32 from sqlalchemy.dialects.sqlite import insert |
33 from sqlalchemy.engine import Connection, Engine | |
28 from sqlalchemy.exc import IntegrityError, NoResultFound | 34 from sqlalchemy.exc import IntegrityError, NoResultFound |
35 from sqlalchemy.ext.asyncio import AsyncEngine, AsyncSession, create_async_engine | |
36 from sqlalchemy.future import select | |
29 from sqlalchemy.orm import ( | 37 from sqlalchemy.orm import ( |
30 sessionmaker, subqueryload, joinedload, selectinload, contains_eager | 38 contains_eager, |
39 joinedload, | |
40 selectinload, | |
41 sessionmaker, | |
42 subqueryload, | |
31 ) | 43 ) |
44 from sqlalchemy.orm.attributes import Mapped | |
32 from sqlalchemy.orm.decl_api import DeclarativeMeta | 45 from sqlalchemy.orm.decl_api import DeclarativeMeta |
33 from sqlalchemy.orm.attributes import Mapped | 46 from sqlalchemy.sql.functions import coalesce, count, now, sum as sum_ |
34 from sqlalchemy.future import select | |
35 from sqlalchemy.engine import Engine, Connection | |
36 from sqlalchemy import update, delete, and_, or_, event, func | |
37 from sqlalchemy.sql.functions import coalesce, sum as sum_, now, count | |
38 from sqlalchemy.dialects.sqlite import insert | |
39 from sqlalchemy import text, literal_column, Integer | |
40 from alembic import script as al_script, config as al_config | |
41 from alembic.runtime import migration as al_migration | |
42 from twisted.internet import defer | 47 from twisted.internet import defer |
43 from twisted.words.protocols.jabber import jid | 48 from twisted.words.protocols.jabber import jid |
44 from twisted.words.xish import domish | 49 from twisted.words.xish import domish |
45 from sat.core.i18n import _ | 50 |
46 from sat.core import exceptions | 51 from sat.core import exceptions |
47 from sat.core.log import getLogger | |
48 from sat.core.constants import Const as C | 52 from sat.core.constants import Const as C |
49 from sat.core.core_types import SatXMPPEntity | 53 from sat.core.core_types import SatXMPPEntity |
50 from sat.tools.utils import aio, as_future | 54 from sat.core.i18n import _ |
51 from sat.tools.common import uri | 55 from sat.core.log import getLogger |
52 from sat.memory import migration | 56 from sat.memory import migration |
53 from sat.memory import sqla_config | 57 from sat.memory import sqla_config |
54 from sat.memory.sqla_mapping import ( | 58 from sat.memory.sqla_mapping import ( |
55 NOT_IN_EXTRA, | |
56 SyncState, | |
57 Base, | 59 Base, |
58 Profile, | |
59 Component, | 60 Component, |
61 File, | |
60 History, | 62 History, |
61 Message, | 63 Message, |
62 Subject, | 64 NOT_IN_EXTRA, |
63 Thread, | |
64 ParamGen, | 65 ParamGen, |
65 ParamInd, | 66 ParamInd, |
66 PrivateGen, | 67 PrivateGen, |
68 PrivateGenBin, | |
67 PrivateInd, | 69 PrivateInd, |
68 PrivateGenBin, | |
69 PrivateIndBin, | 70 PrivateIndBin, |
70 File, | 71 Profile, |
72 PubsubItem, | |
71 PubsubNode, | 73 PubsubNode, |
72 PubsubItem, | 74 Subject, |
75 SyncState, | |
76 Thread, | |
73 ) | 77 ) |
78 from sat.tools.common import uri | |
79 from sat.tools.utils import aio, as_future | |
74 | 80 |
75 | 81 |
76 log = getLogger(__name__) | 82 log = getLogger(__name__) |
77 migration_path = Path(migration.__file__).parent | 83 migration_path = Path(migration.__file__).parent |
78 #: mapping of Libervia search query operators to SQLAlchemy method name | 84 #: mapping of Libervia search query operators to SQLAlchemy method name |