Following minimal code worked fine with julia 0.6.4, but does not work with 1.0.0.
Defining a minimal module:
module TestModule
using SQLite
fp = ""
const db = SQLite.DB(fp)
end
Loading the module and execute operations:
using TestModule
SQLite.query(TestModule.db, "SELECT ROWID,* FROM " * "table1")
SQLite.query(SQLite.DB(""), "SELECT ROWID,* FROM " * "table1")
Following exceptions are thrown:
SQLite.SQLiteException("Cannot operate on null pointer")
SQLite.SQLiteException("no such table: table1")
Hence, somehow the constant definition within the module does not work as it did in 0.6.4. Any ideas how I can fix that?
Shouldnβt it be
SQLite.query(TestModule.db, "SELECT ROWID,* FROM " * βtable1β)
You donβt include code to create/populate table1, but creating one with a couple of int columns and inserting a couple of rows gives me
julia> SQLite.query(TestModule.db, "SELECT ROWID,* FROM " * "table1")
2Γ3 DataFrame
β Row β rowid β i β j β
βββββββΌββββββββΌββββΌββββ€
β 1 β 1 β 1 β 2 β
β 2 β 2 β 2 β 3 β
julia> versioninfo()
Julia Version 1.0.0
Commit 5d4eaca0c9 (2018-08-08 20:58 UTC)
Platform Info:
OS: Windows (x86_64-w64-mingw32)
CPU: Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-6.0.0 (ORCJIT, skylake)
Environment:
JULIA_NUM_THREADS = 4
julia> Pkg.installed()["SQLite"]
v"0.6.0"
Thanks for the answer! Your are right: There is no table1 as there is also no database. However, the point I was trying to stress out, is the fact, that the constant declaration in the module does not seem to work in v1.0.0. In v0.6.4. it worked though.
Assuming there is a database with table1 the first query will still give you the βCannot operate on null pointerβ error, whereas the second query will return table1 of the database. My question is therefore why does the constant declaration not work as in v0.6.4., is it an SQLite problem and how can it be fixed?
In the example posted you create a const TestModule.db then try to use SQLite.db
To clarify, do you mean itβs working now or that youβve amended the example (and if so, do you still get the same exception)
Precompiling seems to be causing the problem.
Putting __precompile__(false)
at the beginning of the module, solves the issue at least for now.
Better using the __init__()
function, see here.
1 Like