def __init__(self, pool=None, testing=False):
        if pool is not None:
            self.pool = pool
            self.transactor = Transactor(pool)

        self.started = False
        self.__testing = testing

        if not self.zstorm_configured:
            provideUtility(global_zstorm, IZStorm)
            self._patch_sqlite_uris()
            self._set_zstorm_default_uris(getUtility(IZStorm))

        SQLite.register()
        MySQL.register()
        PostgreSQL.register()
Exemple #2
0
 def produce(self):
     if self.scheme == 'sqlite':
         return SQLite(self.model)
     elif self.scheme == 'mysql':
         return MySQL(self.model)
     elif self.scheme == 'postgres':
         return PostgreSQL(self.model)
     else:
         return CommonSQL(self.model)
Exemple #3
0
    def __init__(self, pool=None, testing=False):
        if pool is not None:
            self.pool = pool
            self.transactor = Transactor(pool)

        self.started = False
        self.__testing = testing

        if not self.zstorm_configured:
            provideUtility(global_zstorm, IZStorm)
            zstorm = getUtility(IZStorm)
            if self.backend == 'sqlite' and sqlite_version_info >= (3, 6, 19):
                uri = '{}?foreign_keys=1'.format(config.Database().uri)
            else:
                uri = config.Database().uri
            zstorm.set_default_uri('mamba', uri)

        SQLite.register()
        MySQL.register()
        PostgreSQL.register()
Exemple #4
0
    def __init__(self, pool=None, testing=False):
        if pool is not None:
            self.pool = pool
            self.transactor = Transactor(pool)

        self.started = False
        self.__testing = testing

        if not self.zstorm_configured:
            provideUtility(global_zstorm, IZStorm)
            zstorm = getUtility(IZStorm)
            if self.backend == 'sqlite' and sqlite_version_info >= (3, 6, 19):
                uri = '{}?foreign_keys=1'.format(config.Database().uri)
            else:
                uri = config.Database().uri
            zstorm.set_default_uri('mamba', uri)

        SQLite.register()
        MySQL.register()
        PostgreSQL.register()
Exemple #5
0
    def __init__(self, pool=None, testing=False):
        if pool is not None:
            self.pool = pool

        self.started = False
        self.__testing = testing

        if not self.zstorm_configured:
            provideUtility(global_zstorm, IZStorm)
            zstorm = getUtility(IZStorm)
            zstorm.set_default_uri('mamba', config.Database().uri)

        SQLite.register()
        MySQL.register()
        PostgreSQL.register()

        # MonkeyPatch Storm
        if not self.monkey_patched:
            monkey_patcher = MonkeyPatcher(
                (properties, 'PropertyColumn', PropertyColumnMambaPatch))
            monkey_patcher.patch()
            self.monkey_patched = True
Exemple #6
0
    def __init__(self, pool=None, testing=False):
        if pool is not None:
            self.pool = pool

        self.started = False
        self.__testing = testing

        if not self.zstorm_configured:
            provideUtility(global_zstorm, IZStorm)
            zstorm = getUtility(IZStorm)
            zstorm.set_default_uri('mamba', config.Database().uri)

        SQLite.register()
        MySQL.register()
        PostgreSQL.register()

        # MonkeyPatch Storm
        if not self.monkey_patched:
            monkey_patcher = MonkeyPatcher(
                (properties, 'PropertyColumn', PropertyColumnMambaPatch)
            )
            monkey_patcher.patch()
            self.monkey_patched = True
Exemple #7
0
    def test_sqlite_raises_missing_primary_key_exception(self):

        dummy = NotPrimaryModel()

        sqlite = SQLite(dummy)
        self.assertRaises(SQLiteMissingPrimaryKey, sqlite.detect_primary_key)