Provide a way to start an SQLite `IMMEDIATE` transaction
Discussed in https://github.com/SeaQL/sea-orm/discussions/2691
Originally posted by raffomania August 12, 2025
One of the recommended best practices when running SQLite for a web application is to start write transactions as IMMEDIATE so SQLite will respect the busy_timeout setting.
Looking at the TransactionTrait::begin_with_config function, it doesn't seem like this is currently supported. I'd be interested in working on a PR for this if we can work out a good API for this. Would anybody be interested in talking about the API design and/or reviewing a PR?
enum Config {
Postgres(PostgresConfig),
Sqlite(SqliteConfig),
Mysql(MysqlConfig)
}
// or
struct Config {
// Controlled by feature flag
}
// If multiple backend features are enabled, check the backend of connection here or simply ignore that.
async fn begin_with_config(
&self,
conf: Config
) -> Result<DatabaseTransaction, DbErr>;
@Expurple @tyt2y3 What do you think?
Hey is there any updates on this? We run into problems when we get a lot of requests at the same time and it appears that Sqlite does not respect the busy_timeout setting