Ecto Oracle adapter

Is this understanding correct so far?

Yes it is!

2 Likes

Changed :smiley:

One of the things I keep in mind when naming threads is asking myself what somebody might search for in a search engine for that topic, and usually people will search for things like “Elixir Postgres driver” or “Elixir Oracle adapter” :slight_smile: but Ecto Oracle adapter is cool too if you’d prefer that :023:

I’m sure you’ll get there :003:

3 Likes

Makes perfect sense. Didn’t think of the search engines :blush:

1 Like

I got DBConnection.prepare_execute working (yay :slight_smile:) which is fetch everything untill end of table.

Next step is to do the cursor, i.e. fetch in batches. I implemneted handle_declare/4 and handle_fetch/4 functions. Now I am stuck trying to invoke them! As per my undertsanding above I should call prepare_stream/4, but unlike prepare_execute/4 the first argument of prepare_stream/4 is t() (%DBConnection{}) and not GenServer.server(). DBConnection.start_link only gives back a {:ok, pid()} (which seems to be same as GenServer.server()).

How do I get a t() from DBConnection.start_link?

TIA

Streaming must happen inside a transaction, see: DBConnection.transaction/3. The fun passed to transaction/3 gets the t().

4 Likes

Here is the first working version (very much alpha) of the driver https://github.com/c-bik/OraLixir

This is still work-in-progress. Not all DBConnection callbacls are (correctly)implemented.
But connect and query is possible.

Some examples

iex> {:ok, pid} = OraLixir.start_link([])
{:ok, #PID<0.69.0>}
iex> OraLixir.prepare_execute(pid, "name", "SELECT 'string', 1, sysdate FROM DUAL", [], [])
{:ok, %OraLixir.Query{}, %OraLixir.Result{}}

I will very much appreciate any comment / verification / feedback / code review and general guidence etc for me to improve on this.

TIA

5 Likes

Hi all,

An update on development progress and current status of OraLixir : An Ecto Adapter for Oracle

OraLixir.Connection use DBConnection tests are now passing in Travis

==> 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)
Generated oralixir app
.Table OraLixir_test dropped if existed
Table OraLixir_test created : CREATE TABLE OraLixir_test (COL1 NUMBER, COL2 VARCHAR2(1000))
First row inserted to OraLixir_test : INSERT INTO OraLixir_test (COL1, COL2) VALUES(1, 'one')
Second row inserted to OraLixir_test : INSERT INTO OraLixir_test (COL1, COL2) VALUES(2, 'two')
All rows selected from OraLixir_test : SELECT * FROM OraLixir_test
Updated one row in OraLixir_test : UPDATE OraLixir_test SET COL1=3, COL2='three' WHERE COL1=2
All rows selected from OraLixir_test (including updated) : SELECT * FROM OraLixir_test
truncated all rows from OraLixir_test : UPDATE OraLixir_test SET COL1=3, COL2='three' WHERE COL1=2
No rows selected from OraLixir_test (after truncate) : SELECT * FROM OraLixir_test

The mix tests will also serve as interface documentation if anyone already would like to try it out at Connection interface level.

Thanks a lot @Cruz for all your help in testing and improvement advices.

I will very much appreciate if I get some code/design review on what I have so far.

Currently working / learning on how get into Ecto.Adapters.SQL implementation for OraLixir.

4 Likes

In jamdb_oracle prepare_stream/4 is not declared at all, only stream/4 and handle_fetch/3 are implemented.