Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQLite.load! fails inside transaction #341

Open
TheZXCVQ opened this issue Apr 19, 2024 · 2 comments
Open

SQLite.load! fails inside transaction #341

TheZXCVQ opened this issue Apr 19, 2024 · 2 comments

Comments

@TheZXCVQ
Copy link

When executing example code below

using SQLite
using TypedTables

db=SQLite.DB("test.db")

SQLite.execute(db,"""
CREATE TABLE IF NOT EXISTS test_table (
	id INTEGER PRIMARY KEY,
   	number INTEGER
)
""")

table_to_insert=Table(id=[1,2,3], number=[6,2,8])
try
    SQLite.transaction(db)
    SQLite.load!(table_to_insert, db, "test_table")
    SQLite.commit(db)
catch e
    SQLite.rollback(db)
    throw(e)
end

It on SQLite.load! throws ERROR: SQLiteException("Safety level may not be changed inside a transaction")

@caleb-allen
Copy link

I'm experiencing something similar with intermittent errors calling load!, although I haven't been able to confirm the precise scenario that causes it.

It seems to only occur shortly after initializing a new database, or a new table. It appears that if load! does not throw this SQLiteException on the first call to the method, it does not throw it on subsequent calls.

@Zentrik
Copy link

Zentrik commented Oct 3, 2024

You can comment out

execute(db, "PRAGMA synchronous = OFF;")
and
execute(db, "PRAGMA synchronous = ON;")
to get around it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants