import peewee as pv from playhouse import signals, sqlite_ext from time import time import json import shortuuid from .builder import Conf, DConf from ..fields import ArrayField, X1fField, JSONField from ..util import field_checksum, stripHTMLMedia database = sqlite_ext.SqliteExtDatabase(None, regexp_function=True) class BaseModel(signals.Model): class Meta: database = database # Missing tables in Anki class Decks(BaseModel): # Use auto-increment instead of time in Epoch seconds to ensure uniqueness id = pv.AutoField() name = pv.TextField(unique=True) class Models(BaseModel): # Use auto-increment instead of time in Epoch seconds to ensure uniqueness
import peewee as pv from playhouse import signals, sqlite_ext from time import time import json import shortuuid from ankisync2.builder import Conf, DConf from ankisync2.util import field_checksum, stripHTMLMedia, DataclassJSONEncoder __all__ = ("database", "Decks", "Models", "Templates", "Col", "Notes", "Cards", "Revlog", "Graves") database = sqlite_ext.SqliteExtDatabase(None) class BaseModel(signals.Model): class Meta: database = database class ArrayField(pv.TextField): separator = ' ' def db_value(self, value): return self.separator.join(value) def python_value(self, value): return value.split(self.separator) class ArrayFieldPadded(ArrayField):
import objective_turk.color_logs import mturk CASCADE = "CASCADE" NO_ACTION = "NO ACTION" logger = logging.getLogger(__name__) logger.setLevel(logging.DEBUG) class Environment(enum.Enum): sandbox = "sandbox" production = "production" _database: peewee.Database = peewee_sqlite.SqliteExtDatabase(None) _environment: typing.Optional[Environment] = None _client = None _init = False def get_current_environment() -> typing.Optional[Environment]: return _environment def get_database() -> peewee.Database: return _database def print_production_warning() -> None: """
def __init__(self, file): self._db = sqlite.SqliteExtDatabase(file) db_proxy.initialize(self._db) self._db.create_tables([Gene, Word])