Example #1
0
from typing import Optional, Callable, Deque, Union, List

from sqlalchemy.ext.declarative import DeclarativeMeta

from dbsync.core import SQLClass
from sqlalchemy import event
from sqlalchemy.engine import Connection
from sqlalchemy.orm import Mapper
from sqlalchemy.orm.session import Session as GlobalSession, Session

from dbsync import core
from dbsync.models import Operation, SkipOperation, call_before_tracking_fn, call_after_tracking_fn
from dbsync.logs import get_logger
from sqlalchemy.sql import Join

logger = get_logger(__name__)

if core.mode == 'server':
    warnings.warn("don't import both client and server")
core.mode = 'client'

#: Operations to be flushed to the database after a commit.
_operations_queue: Deque[Operation] = deque()


def flush_operations(committed_session):
    """Flush operations after a commit has been issued."""
    if not _operations_queue or \
            getattr(committed_session, core.INTERNAL_SESSION_ATTR, False):
        return
    if not core.listening:
Example #2
0
"""

import logging
import inspect
import warnings
from collections import deque

from sqlalchemy import event
from sqlalchemy.orm.session import Session as GlobalSession

from dbsync import core
from dbsync.models import Operation
from dbsync.logs import get_logger


logger = get_logger(__name__)


if core.mode == 'server':
    warnings.warn("don't import both client and server")
core.mode = 'client'


#: Operations to be flushed to the database after a commit.
_operations_queue = deque()


def flush_operations(committed_session):
    "Flush operations after a commit has been issued."
    if not _operations_queue or \
            getattr(committed_session, core.INTERNAL_SESSION_ATTR, False):