You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/index.md
+24-20Lines changed: 24 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,14 +5,8 @@
5
5
6
6
## High-level interface
7
7
```@docs
8
-
SQLite.query
9
-
SQLite.load
10
-
```
11
-
12
-
## Lower-level utilities
13
-
```@docs
14
-
SQLite.Source
15
-
SQLite.Sink
8
+
SQLite.Query
9
+
SQLite.load!
16
10
```
17
11
18
12
## Types/Functions
@@ -59,11 +53,21 @@ SQLite.Sink
59
53
Used to execute a prepared `SQLite.Stmt`. The 2nd method is a convenience method to pass in an SQL statement as a string which gets prepared and executed in one call. This method does not check for or return any results, hence it is only useful for database manipulation methods (i.e. ALTER, CREATE, UPDATE, DROP). To return results, see `SQLite.query` below.
Constructs a `SQLite.Query` object by executing the SQL query `sql` against the sqlite database `db` and querying
59
+
the columns names and types of the result set, if any.
63
60
64
-
An SQL statement `sql` is prepared, executed in the context of `db`, and results, if any, are returned. The return value is a `Data.Table` by default from the `DataStreams.jl` package. The `Data.Table` has a field `.data` which is a `Vector{NullableVector}` which holds the columns of data returned from the `sql` statement.
61
+
Will bind `values` to any parameters in `sql`.
62
+
`stricttypes=false` will remove strict column typing in the result set, making each column effectively `Vector{Any}`; in sqlite, individual
63
+
column values are only loosely associated with declared column types, and instead each carry their own type information. This can lead to
64
+
type errors when trying to query columns when a single type is expected.
65
+
`nullable` controls whether `null` (`missing` in Julia) values are expected in a column.
65
66
66
-
The values in `values` are used in parameter binding (see `bind!` above). If your statement uses nameless parameters `values` must be a `Vector` of the values you wish to bind to your statment. If your statement uses named parameters `values` must be a Dict where the keys are of type `Symbol`. The key must match an identifier name in the statement (the name **should not** include the ':', '@' or '$' prefix).
67
+
An `SQLite.Query` object will iterate NamedTuple rows by default, and also supports the Tables.jl interface for integrating with
68
+
any other Tables.jl implementation. Due note however that iterating an sqlite result set is a forward-once-only operation. If you need
69
+
to iterate over an `SQLite.Query` multiple times, but can't store the iterated NamedTuples, call `SQLite.reset!(q::SQLite.Query)` to
70
+
re-execute the query and position the iterator back at the begining of the result set.
@@ -135,15 +139,15 @@ julia> db = SQLite.DB("Chinook_Sqlite.sqlite")
135
139
136
140
julia># using SQLite's in-built syntax
137
141
138
-
julia> SQLite.query(db, "SELECT FirstName, LastName FROM Employee WHERE LastName REGEXP 'e(?=a)'")
142
+
julia> SQLite.Query(db, "SELECT FirstName, LastName FROM Employee WHERE LastName REGEXP 'e(?=a)'")|> DataFrame
139
143
1x2 ResultSet
140
144
| Row |"FirstName"|"LastName"|
141
145
|-----|-------------|------------|
142
146
|1|"Jane"|"Peacock"|
143
147
144
148
julia># explicitly calling the regexp() function
145
149
146
-
julia> SQLite.query(db, "SELECT * FROM Genre WHERE regexp('e[trs]', Name)")
150
+
julia> SQLite.Query(db, "SELECT * FROM Genre WHERE regexp('e[trs]', Name)")|> DataFrame
147
151
6x2 ResultSet
148
152
| Row |"GenreId"|"Name"|
149
153
|-----|-----------|----------------------|
@@ -156,20 +160,20 @@ julia> SQLite.query(db, "SELECT * FROM Genre WHERE regexp('e[trs]', Name)")
156
160
157
161
julia># you can even do strange things like this if you really want
158
162
159
-
julia> SQLite.query(db, "SELECT * FROM Genre ORDER BY GenreId LIMIT 2")
163
+
julia> SQLite.Query(db, "SELECT * FROM Genre ORDER BY GenreId LIMIT 2")|> DataFrame
160
164
2x2 ResultSet
161
165
| Row |"GenreId"|"Name"|
162
166
|-----|-----------|--------|
163
167
|1|1|"Rock"|
164
168
|2|2|"Jazz"|
165
169
166
-
julia> SQLite.query(db, "INSERT INTO Genre VALUES (regexp('^word', 'this is a string'), 'My Genre')")
170
+
julia> SQLite.Query(db, "INSERT INTO Genre VALUES (regexp('^word', 'this is a string'), 'My Genre')")|> DataFrame
167
171
1x1 ResultSet
168
172
| Row |"Rows Affected"|
169
173
|-----|-----------------|
170
174
|1|0|
171
175
172
-
julia> SQLite.query(db, "SELECT * FROM Genre ORDER BY GenreId LIMIT 2")
176
+
julia> SQLite.Query(db, "SELECT * FROM Genre ORDER BY GenreId LIMIT 2")|> DataFrame
173
177
2x2 ResultSet
174
178
| Row |"GenreId"|"Name"|
175
179
|-----|-----------|------------|
@@ -180,13 +184,13 @@ julia> SQLite.query(db, "SELECT * FROM Genre ORDER BY GenreId LIMIT 2")
180
184
Due to the heavy use of escape characters you may run into problems where julia parses out some backslashes in your query, for example `"\y"` simply becomes `"y"`. For example the following two queries are identical
181
185
182
186
```julia
183
-
julia> SQLite.query(db, "SELECT * FROM MediaType WHERE Name REGEXP '-\d'")
187
+
julia> SQLite.Query(db, "SELECT * FROM MediaType WHERE Name REGEXP '-\d'")|> DataFrame
184
188
1x1 ResultSet
185
189
| Row |"Rows Affected"|
186
190
|-----|-----------------|
187
191
|1|0|
188
192
189
-
julia> SQLite.query(db, "SELECT * FROM MediaType WHERE Name REGEXP '-d'")
193
+
julia> SQLite.Query(db, "SELECT * FROM MediaType WHERE Name REGEXP '-d'")|> DataFrame
190
194
1x1 ResultSet
191
195
| Row |"Rows Affected"|
192
196
|-----|-----------------|
@@ -198,15 +202,15 @@ This can be avoided in two ways. You can either escape each backslash yourself o
198
202
```julia
199
203
julia># manually escaping backslashes
200
204
201
-
julia> SQLite.query(db, "SELECT * FROM MediaType WHERE Name REGEXP '-\\d'")
205
+
julia> SQLite.Query(db, "SELECT * FROM MediaType WHERE Name REGEXP '-\\d'")|> DataFrame
Base.depwarn("`SQLite.Sink(db, name)` is deprecated in favor of calling `SQLite.load!(table, db, name)` where `table` can be any Tables.jl interface implementation", nothing)
@@ -86,13 +78,22 @@ Load a Data.Source `source` into an SQLite table that will be named `tablename`
86
78
`ifnotexists=false` will throw an error if `tablename` already exists in `db`
87
79
"""
88
80
functionload(db::SQLite.DB, name, ::Type{T}, args...; append::Bool=false, transforms::Dict=Dict{Int,Function}(), kwargs...) where {T}
81
+
Base.depwarn("`SQLite.load(db, name, args...)` is deprecated in favor of calling `SQLite.load!(table, db, name)` where `table` can be any Tables.jl interface implementation", nothing)
functionload(db::SQLite.DB, name, source::T; append::Bool=false, transforms::Dict=Dict{Int,Function}(), kwargs...) where {T}
86
+
Base.depwarn("`SQLite.load(db, name, args...)` is deprecated in favor of calling `SQLite.load!(table, db, name)` where `table` can be any Tables.jl interface implementation", nothing)
functionload(sink::Sink, ::Type{T}, args...; append::Bool=false, transforms::Dict=Dict{Int,Function}()) where {T}
92
+
Base.depwarn("`SQLite.load(sink::SQLite.Sink, args...)` is deprecated in favor of calling `SQLite.load!(table, db, name)` where `table` can be any Tables.jl interface implementation", nothing)
Base.depwarn("`SQLite.load(sink::SQLite.Sink, args...)` is deprecated in favor of calling `SQLite.load!(table, db, name)` where `table` can be any Tables.jl interface implementation", nothing)
0 commit comments