Comments (9)
I still get the MethodError of isdone as intially commented using 0.7.0 version of this package and julia 1.1.0, what could be the reason?
from libpq.jl.
Could you give a stack trace for the error?
from libpq.jl.
datat = (time = 63240480000000, symbol = "000001", macd = 0.13217593007179484, diff = 0.11147362266779684, dea = 0.020702307403998005)
Data.stream!(
datat,
LibPQ.Statement,
conn,
"INSERT INTO macd (time, symbol, macd, diff, dea) VALUES (\$1, \$2, \$3, \$4, \$5);",
)
MethodError: no method matching isdone(::NamedTuple{(:time, :symbol, :macd, :diff, :dea),Tuple{Int64,String,Float64,Float64,Float64}}, ::Int64, ::Int64)
You may have intended to import Base.isdone
Closest candidates are:
isdone(::Any, ::Any, ::Any, !Matched::Any, !Matched::Any) at /home/gsc/.julia/packages/DataStreams/saxcP/src/DataStreams.jl:152
isdone(!Matched::Array{T,1} where T<:NamedTuple, ::Any, ::Any) at /home/gsc/.julia/packages/DataStreams/saxcP/src/namedtuples.jl:6
isdone(!Matched::Array{T,1} where T<:NamedTuple, ::Any, ::Any, !Matched::Any, !Matched::Any) at /home/gsc/.julia/packages/DataStreams/saxcP/src/namedtuples.jl:4
...
Stacktrace:
[1] isdone(::NamedTuple{(:time, :symbol, :macd, :diff, :dea),Tuple{Int64,String,Float64,Float64,Float64}}, ::Int64, ::Int64, ::Int64, ::Int64) at /home/gsc/.julia/packages/DataStreams/saxcP/src/DataStreams.jl:152
[2] macro expansion at /home/gsc/.julia/packages/DataStreams/saxcP/src/query.jl:628 [inlined]
[3] stream!(::NamedTuple{(:time, :symbol, :macd, :diff, :dea),Tuple{Int64,String,Float64,Float64,Float64}}, ::DataStreams.Data.Query{0x01,Tuple{DataStreams.Data.QueryColumn{0x01,Int64,1,1,:time,nothing,()},DataStreams.Data.QueryColumn{0x01,Char,2,2,:symbol,nothing,()},DataStreams.Data.QueryColumn{0x01,Float64,3,3,:macd,nothing,()},DataStreams.Data.QueryColumn{0x01,Float64,4,4,:diff,nothing,()},DataStreams.Data.QueryColumn{0x01,Float64,5,5,:dea,nothing,()}},(),nothing,nothing}, ::Type{DataStreams.Data.Row}, ::LibPQ.Statement, ::DataStreams.Data.Schema{true,Tuple{Int64,Char,Float64,Float64,Float64}}, ::Int64) at /home/gsc/.julia/packages/DataStreams/saxcP/src/query.jl:618
[4] #stream!#113(::Bool, ::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::NamedTuple{(:time, :symbol, :macd, :diff, :dea),Tuple{Int64,String,Float64,Float64,Float64}}, ::DataStreams.Data.Query{0x01,Tuple{DataStreams.Data.QueryColumn{0x01,Int64,1,1,:time,nothing,()},DataStreams.Data.QueryColumn{0x01,Char,2,2,:symbol,nothing,()},DataStreams.Data.QueryColumn{0x01,Float64,3,3,:macd,nothing,()},DataStreams.Data.QueryColumn{0x01,Float64,4,4,:diff,nothing,()},DataStreams.Data.QueryColumn{0x01,Float64,5,5,:dea,nothing,()}},(),nothing,nothing}, ::Type{LibPQ.Statement}, ::LibPQ.Connection, ::Vararg{Any,N} where N) at /home/gsc/.julia/packages/DataStreams/saxcP/src/query.jl:588
[5] (::getfield(DataStreams.Data, Symbol("#kw##stream!")))(::NamedTuple{(:append,),Tuple{Bool}}, ::typeof(DataStreams.Data.stream!), ::NamedTuple{(:time, :symbol, :macd, :diff, :dea),Tuple{Int64,String,Float64,Float64,Float64}}, ::DataStreams.Data.Query{0x01,Tuple{DataStreams.Data.QueryColumn{0x01,Int64,1,1,:time,nothing,()},DataStreams.Data.QueryColumn{0x01,Char,2,2,:symbol,nothing,()},DataStreams.Data.QueryColumn{0x01,Float64,3,3,:macd,nothing,()},DataStreams.Data.QueryColumn{0x01,Float64,4,4,:diff,nothing,()},DataStreams.Data.QueryColumn{0x01,Float64,5,5,:dea,nothing,()}},(),nothing,nothing}, ::Type{LibPQ.Statement}, ::LibPQ.Connection, ::Vararg{Any,N} where N) at ./none:0
[6] #stream!#111(::Bool, ::Dict{Int64,Function}, ::Function, ::Array{Any,1}, ::Array{Any,1}, ::Nothing, ::Nothing, ::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::typeof(DataStreams.Data.stream!), ::NamedTuple{(:time, :symbol, :macd, :diff, :dea),Tuple{Int64,String,Float64,Float64,Float64}}, ::Type{LibPQ.Statement}, ::LibPQ.Connection, ::Vararg{Any,N} where N) at /home/gsc/.julia/packages/DataStreams/saxcP/src/query.jl:538
[7] stream!(::NamedTuple{(:time, :symbol, :macd, :diff, :dea),Tuple{Int64,String,Float64,Float64,Float64}}, ::Type{LibPQ.Statement}, ::LibPQ.Connection, ::String) at /home/gsc/.julia/packages/DataStreams/saxcP/src/query.jl:516
[8] top-level scope at In[40]:1
from libpq.jl.
Ah, DataStreams requires your data to be either a Vector of NamedTuples or a NamedTuple of Vectors. The easiest thing in your case is to just do:
Data.stream!(
[datat],
LibPQ.Statement,
conn,
"INSERT INTO macd (time, symbol, macd, diff, dea) VALUES (\$1, \$2, \$3, \$4, \$5);",
)
from libpq.jl.
Thanks. It works!
from libpq.jl.
Great!
from libpq.jl.
When there is only one datat of NamedTuple it works. If there is an array of NamedTuples it would through me an error like:
MethodError: no method matching schema(::Array{Any,1})
Closest candidates are:
schema(::S, !Matched::DataStreams.Data.Query{code,columns,e,limit,offset}) where {code, S, columns, e, limit, offset} at /home/gsc/.julia/packages/DataStreams/saxcP/src/query.jl:217
schema(::S, !Matched::DataStreams.Data.Query{code,columns,e,limit,offset}, !Matched::Any) where {code, S, columns, e, limit, offset} at /home/gsc/.julia/packages/DataStreams/saxcP/src/query.jl:217
schema(!Matched::LibPQ.Result) at /home/gsc/.julia/packages/LibPQ/LODsS/src/datastreams.jl:4
...
Stacktrace:
[1] #stream!#111(::Bool, ::Dict{Int64,Function}, ::Function, ::Array{Any,1}, ::Array{Any,1}, ::Nothing, ::Nothing, ::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::typeof(DataStreams.Data.stream!), ::Array{Any,1}, ::Type{LibPQ.Statement}, ::LibPQ.Connection, ::Vararg{Any,N} where N) at /home/gsc/.julia/packages/DataStreams/saxcP/src/query.jl:534
[2] stream!(::Array{Any,1}, ::Type{LibPQ.Statement}, ::LibPQ.Connection, ::String) at /home/gsc/.julia/packages/DataStreams/saxcP/src/query.jl:516
[3] top-level scope at ./In[114]:22
when I run
Data.stream!(
data_list,
LibPQ.Statement,
conn,
"INSERT INTO " * dbName * string(param) * " (time, symbol, sma)
VALUES (\$1, \$2, \$3) ON CONFLICT (time, symbol) DO NOTHING;")
When I declare data_list as data_list = Vector(undef, 0)
. What is the correct way to use it as " Vector of NamedTuples " ?
from libpq.jl.
The eltype of the Vector needs to be a specific NamedTuple type, e.g. you'll need
Vector{NamedTuple{(:time, :symbol, :macd, :diff, :dea),Tuple{Int64,String,Float64,Float64,Float64}}}(undef, 0)
from libpq.jl.
Thanks!
from libpq.jl.
Related Issues (20)
- Memory Leak? HOT 4
- LibPQ and local peer trust ("ident") HOT 4
- All rational numbers are parsed as Decimals.Decimal instead of Float HOT 3
- Trying to implement large object support HOT 4
- Large select queries running 5-10x slower than with psql HOT 7
- Support UUIDs with binary_format=true HOT 1
- Make Tables.rowtable(result) as fast as Tables.rowtable(Tables.columntable(result))
- `tryparse` Inexact Error HOT 5
- Docs links return 404 HOT 3
- Using array_agg results in a string HOT 2
- I install LibPQ but test fails. HOT 1
- Guess when there is no server running in tests and suggest users install one
- Multiple `async_execute`s may not always execute in sequence?
- `execute` and `async_execute` exception handling difference
- `LibPQ`.`async_execute`'s overhead is around 3ms HOT 2
- Add functions for closing prepared statements (requires PostgreSQL 17 release and corresponding libpq_jll)
- Can't suppress LibPQ's error output HOT 2
- Conflict with Dates.jl HOT 1
- Can't store Vector{UInt8} as expected in bytea
- New Release? HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libpq.jl.