-
Notifications
You must be signed in to change notification settings - Fork 81
Closed
Description
# src/SQLite.jl:257
function juliatype(handle, col)
t = SQLite.sqlite3_column_decltype(handle, col)
if t != C_NULL
T = juliatype(unsafe_string(t))
T !== Any && return T
end
x = SQLite.sqlite3_column_type(handle, col)
if x == SQLite.SQLITE_BLOB
val = SQLite.sqlitevalue(Any, handle, col)
return typeof(val)
else
return juliatype(x)
end
end
juliatype(x::Integer) = x == SQLITE_INTEGER ? Int : x == SQLITE_FLOAT ? Float64 : x == SQLITE_TEXT ? String : Any
juliatype(x::String) = x == "INTEGER" ? Int : x in ("NUMERIC","REAL") ? Float64 : x == "TEXT" ? String : Any
CREATE TABLE prices (
id INTEGER primary key AUTOINCREMENT not null,
name Text,
price Float NOT NULL,
create_dt datetime not null default (datetime('now','localtime'))
)
julia>
julia> SQLite.sqlite3_column_decltype(sqq.stmt.handle, 1) |> unsafe_string
"INTEGER"
julia> SQLite.sqlite3_column_decltype(sqq.stmt.handle, 2) |> unsafe_string
"Text"
julia> SQLite.sqlite3_column_decltype(sqq.stmt.handle, 3) |> unsafe_string
"Float"
julia> SQLite.sqlite3_column_decltype(sqq.stmt.handle, 4) |> unsafe_string
"datetime"
julia> SQLite.sqlite3_column_type(sqq.stmt.handle, 0)
5
julia> SQLite.sqlite3_column_type(sqq.stmt.handle, 1)
5
julia> SQLite.sqlite3_column_type(sqq.stmt.handle, 2)
5
julia> SQLite.sqlite3_column_type(sqq.stmt.handle, 3)
5
julia> SQLite.sqlite3_column_type(sqq.stmt.handle, 4)
5
julia> SQLite.sqlite3_column_type(sqq.stmt.handle, 5)
5
julia> sqct |> print
CREATE TABLE prices (
id INTEGER primary key AUTOINCREMENT not null,
name text,
price float NOT NULL,
create_dt datetime not null default (datetime('now','localtime'))
)
julia> SQLite.sqlite3_column_decltype(sqf.stmt.handle, 1) |> unsafe_string
"INTEGER"
julia> SQLite.sqlite3_column_decltype(sqf.stmt.handle, 2) |> unsafe_string
"text"
julia> SQLite.sqlite3_column_decltype(sqf.stmt.handle, 3) |> unsafe_string
"float"
julia> SQLite.sqlite3_column_decltype(sqf.stmt.handle, 4) |> unsafe_string
"datetime"
Metadata
Metadata
Assignees
Labels
No labels