mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2026-06-09 16:47:25 +00:00
22 lines
612 B
Kotlin
22 lines
612 B
Kotlin
package full
|
|
|
|
import com.benasher44.uuid.uuid4
|
|
import org.jetbrains.exposed.v1.jdbc.Database
|
|
import org.jetbrains.exposed.v1.jdbc.transactions.transactionManager
|
|
import org.sqlite.JDBC
|
|
import java.io.File
|
|
import java.sql.Connection
|
|
|
|
fun filename() = "${uuid4()}.local.sql".also {
|
|
val file = File(it)
|
|
file.createNewFile()
|
|
file.deleteOnExit()
|
|
}
|
|
fun createDatabase(filename: String) = Database.connect(
|
|
url = "jdbc:sqlite:$filename",
|
|
driver = JDBC::class.qualifiedName!!
|
|
).also {
|
|
it.transactionManager.defaultIsolationLevel = Connection.TRANSACTION_SERIALIZABLE
|
|
it.connector().close()
|
|
}
|