...

Source file src/github.com/ory/x/dbal/dsn.go

Documentation: github.com/ory/x/dbal

     1  package dbal
     2  
     3  import (
     4  	"regexp"
     5  )
     6  
     7  const (
     8  	SQLiteInMemory       = "sqlite://file::memory:?_fk=true"
     9  	SQLiteSharedInMemory = "sqlite://file::memory:?_fk=true&cache=shared"
    10  )
    11  
    12  var dsnRegex = regexp.MustCompile(`^(sqlite://file:(?:.+)\?((\w+=\w+)(&\w+=\w+)*)?(&?mode=memory)(&\w+=\w+)*)$|(?:sqlite://(file:)?:memory:(?:\?\w+=\w+)?(?:&\w+=\w+)*)|^(?:(?::memory:)|(?:memory))$`)
    13  
    14  // SQLite can be written in different styles depending on the use case
    15  // - just in memory
    16  // - shared connection
    17  // - shared but unique in the same process
    18  // see: https://sqlite.org/inmemorydb.html
    19  func IsMemorySQLite(dsn string) bool {
    20  	return dsnRegex.MatchString(dsn)
    21  }
    22  

View as plain text