I try to create and connect to SQLite database in Kotlin using jetbrains.exposed library.
import org.jetbrains.exposed.sql.Database
import org.jetbrains.exposed.sql.SchemaUtils
import org.jetbrains.exposed.sql.transactions.TransactionManager
import org.jetbrains.exposed.sql.transactions.transaction
private fun provideSqliteDatabase(databaseConfig: DatabaseConfig?): Database {
val path = databaseConfig?.url ?: "./"
File(path).mkdirs()
logger.info("SQLite Database path: $path/database.db")
return Database.connect("jdbc:sqlite:$path/database.db", "org.sqlite.JDBC")
.apply {
TransactionManager.manager.defaultIsolationLevel =
Connection.TRANSACTION_READ_UNCOMMITTED
provideTables()
}
}
I try to increase the performance of my database using some PRAGMA SQLite commands. How can I set these configurations such as set JOURNAL_MODE:
PRAGMA JOURNAL_MODE='OFF';
Point: I run my program on Ubuntu 20.04.
CodePudding user response:
I believe you'll have to write plain SQL in this case:
transaction {
exec("PRAGMA JOURNAL_MODE='OFF'", explicitStatementType = StatementType.EXEC)
}
CodePudding user response:
You can try to extend your connection url with journal_mode=OFF
.
If you'll check SQLite driver tests you will find that it parses and executes such parameters automatically.