ncarson / postgres.jl Goto Github PK
View Code? Open in Web Editor NEWPostgres database interface for the Julia language.
License: Other
Postgres database interface for the Julia language.
License: Other
I was just giving a look at the API, and I noticed a small improvement you could make to connect
. Instead of:
function Base.connect(::Type{PostgresServer}, d::Dict)
you could do:
function Base.connect(::Type{PostgresServer}; args...)
This would allow users to write connect(PostgresServer, db="julia_test", host="localhost")
instead of connect(PostgresServer, Dict(:db=>"julia_test", :host=>"localhost"))
.
For more details, see http://docs.julialang.org/en/latest/manual/functions/#keyword-arguments
My two cents...
Attempting to imitate the examples, I did this in julia 0.4 with a Postgres 9.4 database on linux. The error is at the bottom.
julia> using Postgres
INFO: Precompiling module Postgres...
# several failed connection attempts deleted
# BTW, it was not obvious to me that the port should be a string
julia> conn = connect(PostgresServer, "xxx", "xxx", "localhost", "xxx", "5432")
PostgresConnection(@ 0x000000000378dbe0 : ok)
julia> curs = cursor(conn)
Postgres.BufferedPostgresCursor(
PostgresConnection(@ 0x000000000378dbe0 : ok),
Nullable{Postgres.Results.PostgresResult}())
!julia> obs = query(curs, "SELECT isim, id, x, t, y, regular, censor, wait from obs2619 where isim=1")
ERROR: MethodError: `unsafe_column` has no method matching unsafe_column(::Ptr{Postgres.Libpq.PGresult}, ::Int64, ::\
Int32, ::Postgres.Types.PostgresType{Float64})
Closest candidates are:
unsafe_column{T}(::Ptr{Postgres.Libpq.PGresult}, ::Int64, !Matched::Int64, ::Postgres.Types.AbstractPostgresType{T\
})
in column at /home/ross/.julia/v0.4/Postgres/src/results.jl:173
in fetch at /home/ross/.julia/v0.4/Postgres/src/postgres.jl:402
in query at /home/ross/.julia/v0.4/Postgres/src/postgres.jl:418
Postgres decimal / numeric types are decimal floating point values, not binary, and are specifically used instead of the real type for storing things like monetary values where it is critical that the values are exact.
(for example, there are actually legal requirements in the EU about how currency values are handled).
To handle this correctly in Julia, you could use @stevengj's DecFP.jl package, the DecFP.jl Dec128
type will support up to 38 digits.
You might also be able to represent the numeric type with Rational{BigInt}, using a power of 10 for the denominator, that would allow accurately representing any possible Postgres decimal / numeric value without loss of information (Postgres can handle up to 131072 digits before the decimal point; up to 16383 digits after the decimal point).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.