konnexionsgmbh / oralixir Goto Github PK
View Code? Open in Web Editor NEWOracle driver for Elixir
License: Other
Oracle driver for Elixir
License: Other
Currently on macOS 11.1, installed with asdf:
src/dpi.erl:none: error in parse transform 'dpi_transform': {badarith,
[{dpi_transform,nif_stubs,2,
[{file,
"deps/oranif/src/dpi_transform.erl"},
{line,104}]},
{dpi_transform,parse_transform,2,
[{file,
"deps/oranif/src/dpi_transform.erl"},
{line,70}]},
{compile,foldl_transform,3,
[{file,"compile.erl"},
{line,1145}]},
{compile,fold_comp,4,
[{file,"compile.erl"},
{line,416}]},
{compile,internal_comp,5,
[{file,"compile.erl"},
{line,400}]},
{compile,
'-internal_fun/2-anonymous-0-',2,
[{file,"compile.erl"},
{line,229}]},
{compile,
'-do_compile/2-anonymous-0-',1,
[{file,"compile.erl"},
{line,219}]}]}
Specifying:
defp deps do
[
{:oralixir, git: "https://github.com/c-bik/OraLixir", tag: "0.1.0"}
]
end
and running mix deps.get results in the following error:
"error: pathspec '0.1.0' did not match any file(s) known to git."
I was able to download OraLixir after removing the tag:
defp deps do
[
{:oralixir, git: "https://github.com/c-bik/OraLixir"}
]
end
$ mix compile
===> Compiling oranif
c_src/Makefile:6: *** OTP_ERTS_DIR is not set. Stop.
===> Hook for compile failed!
** (Mix) Could not compile dependency :oranif, "/home/cfarfan/.mix/rebar3 bare compile --paths="/home/cfarfan/sandbox/elixir/oratest2/_build/dev/lib/*/ebin"" command failed. You can recompile this dependency with "mix deps.compile oranif", update it with "mix deps.update oranif" or clean it with "mix deps.clean oranif"
The oranif Makefile is still checking for the variable:
ifndef OTP_ERTS_DIR
$(error OTP_ERTS_DIR is not set)
endif
I had issues connecting with the hardcoded "regit" password. Shouldn't the values be in a configuration file?
defp create_context_connection(ora, opts) do
username = Keyword.get(opts, :username, "scott")
password = Keyword.get(opts, :password, "regit")
...
iex(2)> OraLixir.prepare_execute(pid, "name", "DELETE FROM CHANNELS WHERE CHANNEL_ID = 3", [], [])
** (ArgumentError) raise/1 and reraise/2 expect a module name, string or exception as the first argument, got: {:error, %{api: :stmt_getQueryInfo, args: [#Reference<0.1725727705.1425145874.206828>, 1], node: nil, oranifFile: 'c_src/dpiStmt_nif.c', oranifLine: 183, reason: %{action: 'check query position', code: 0, encoding: 'UTF-8', fnName: 'dpiStmt_getQueryInfo', isRecoverable: false, message: 'DPI-1028: query position 1 is invalid', offset: 0, sqlState: 'HY000'}}}
(oralixir) lib/oralixir/connection.ex:136: anonymous fn/4 in OraLixir.Connection.handle_execute/4
(elixir) lib/enum.ex:3019: Enum.reduce_range_dec/4
(oralixir) lib/oralixir/connection.ex:132: OraLixir.Connection.handle_execute/4
(db_connection) lib/db_connection/holder.ex:293: DBConnection.Holder.holder_apply/4
(db_connection) lib/db_connection.ex:1255: DBConnection.run_execute/5
(db_connection) lib/db_connection.ex:1342: DBConnection.run/6
(db_connection) lib/db_connection.ex:540: DBConnection.parsed_prepare_execute/5
(db_connection) lib/db_connection.ex:533: DBConnection.prepare_execute/4
See complete error message in attachment:
OraNif_error.txt
Hello,
The work you've done looks promising! But seems like there is no support of bind variables. I have found a few examples in the tests of oranif
and could make simple code which binds one variable and it seems working:
# INSERT INTO foo(value) VALUES (:1) [param]
param = "example"
%{var: v} = oranif(slave, :conn_newVar, [conn, :DPI_ORACLE_TYPE_VARCHAR, :DPI_NATIVE_TYPE_BYTES, byte_size(param), byte_size(param), true, false, :null])
oranif(slave, :stmt_bindByName, [statement, ":1", v]), label: :stmt_bindByName
oranif(slave, :var_setFromBytes, [v, 0, param]), label: :var_setFromBytes
oranif(slave, :stmt_execute, [statement, []])
So I think theoretically it is doable to add this feature to the library, but I couldn't find any docs about the mapping between data types in Erlang and ODPI and how to basically use bind variables.
I would really appreciate if you could point me to any docs or code where I could find more information about bind variables and how to use them with oranif
๐
$ iex -S mix
Erlang/OTP 22 [erts-10.5.2] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe]
Interactive Elixir (1.9.1) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> {:ok, pid} = OraLixir.start_link([])
{dpi,load_unsafe,87} priv not found
{dpi,load_unsafe,101} PrivDir "/home/cfarfan/sandbox/elixir/oratest/_build/dev/lib/oranif/priv"
{:ok, #PID<0.212.0>}
The directory exist. It is a symlink to /home/cfarfan/sandbox/elixir/oratest/deps/oranif/priv
I was able to use the connection and execute some queries after this warning
==> oralixir
Compiling 5 files (.ex)
warning: function message/1 required by behaviour Exception is not implemented (in module OraLixir.Error)
lib/oralixir/error.ex:1: OraLixir.Error (module)
I have been attempting to make use of OraLixir/Oranif to connect to dozens of oracle databses, and have found an issue.
There is a query that I must fire off about once very five seconds across all of the databases. In this OraLixir is great, as I can do that in a couple of milliseconds.
The problem comes in that, after about one and a half ours of queries, individual connections begin to report that I have reached the maximum number of allowed open cursors. Not all databases reach the limit at the same time, leading me to believe that the issue may simply be some race condition for which cursors may end up being left open.
I amsimply doing
OraLixir.prepare_execute(connection, 'connection_id', query, params, options)
for options I've tried rand_exp backoff with a min time of 30 seconds and a max_restarts of 0
To further add to this, I cannot find any means by which to cleanly request that the connection be closed/disconnected. I'd like to disconnect the connection, and re-establish it when max cursors are reached if there is no simple means by which to prevent the max cursors issue.
Attempting DBConnection.close(connection, query) does not disconnec the connection from the database.
Please let me know if there is something I'm missing.
Thank you.
Shouldn't the title in the instructions be "OraLixir", and the dependencies refer to:
defp deps do
[
{:oralixir, git: "https://github.com/c-bik/OraLixir", tag: "0.1.0"}}
]
end
The Installation section refers to:
{:oralixir, git: "https://github.com/c-bik/OraLixir"}}
But, that line has an extra "}" at the end. It should just be:
{:oralixir, git: "https://github.com/c-bik/OraLixir"}
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.