Skip to content

Support in memory sqlite db #7

Description

@AlecKazakova

specifically the name property of DatabaseConfiguration should be nullable, and when null should mean the created SQLite db is in memory

Activity

  1. kpgalligan commented on Dec 7, 2018

    @kpgalligan
    Contributor

    Hmm. You can use an in memory db with a param, and the name is used so you can have more than one distinct in memory db but also have multiple connections to it. Will think about config more, though.

    https://github.com/touchlab/SQLiter/blob/master/SQLiter/src/commonMain/kotlin/co/touchlab/sqliter/DatabaseConfiguration.kt#L30

    https://github.com/touchlab/SQLiter/blob/master/SQLiter/src/nativeCommonMain/kotlin/co/touchlab/sqliter/NativeFileContext.kt#L33

  2. LouisCAD commented on Dec 2, 2020

    @LouisCAD

    An auto-generated name could be used under the hood when passing null as the name, so every new call creates a database with a different name that won't clash with other instances.

    Example generated name: in_memory_database_1 where the number is taken from a Long that auto-increments.

  3. martinbonnin commented on May 18, 2022

    @martinbonnin
    Contributor

    Just got hit by this. Looks like passing DatabaseConfiguration.inMemory = true and DatabaseConfiguration.name = null is invalid? All my statements fail compilation with this (while it's ok if I pass en actual name). Maybe just throw in that case?

  4. kpgalligan commented on May 18, 2022

    @kpgalligan
    Contributor

    It's not invalid to sqliter, but may be in the context of the sqldelight driver. The basic difference is sqlite lets you create an in memory db with multiple connections using a shared memory cache with a name( "file:${configuration.name}?mode=memory&cache=shared"). However, that needs to be managed and deleted like any other db or it'll just accumulate. Probably not an issue in most cases, but not ideal either.

    A null name creates a connection like you'd usually expect for in memory, but it can only have one connection. The sqldelight driver and sqliter's feature sets probably drifted independently. Will need to actually solve for this. For now, add a name and delete when done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions