
Description
I am trying to use Amazon AWS QLDB (Quantum Ledger Database) with Phoenix/Elixir and the ex_aws_qldb package. I'm not sure if I'm doing it right, honestly, I dont’t know exactly how to use ex_aws_qldb functions to get the results I want. But at least I get a python error which could be an issue.
Could you please check the issue and/or can you explain to me how to use ex_aws_qldb correctly?
Environment
- Elixir 1.9.4
- ex_aws_with_qldb 2.1.2
- ex_aws_qldb 0.1.0
- hackney 1.15.2
Current behavior
What I’ve done so far:
- Create the example ledger database “vehicles-registration” with example data in aws and setting a user in AWS IAM with full access to the ledger database
- Create a Phoenix/Elixir project and Installing the ex_aws_qldb package with all the dependencies
- Create a module “Instructions” with a simple function get_vehicles() as a playground to try out the CRUD szenarios
First of all I try to get a connection to qldb and to query example data from “vehicles-registration” database in the way but definitely not sure if this is correct:
{:ok, session} = ExAws.QLDBSession.start_session("vehicle-registration") |> ExAws.request(region: Application.get_env(:mpp, :aws_region))
{:ok, transaction} = ExAws.QLDBSession.start_transaction(session["StartSession"]["SessionToken"]) |> ExAws.request(region: Application.get_env(:mpp, :aws_region))
{:ok, executeStatement} = ExAws.QLDBSession.execute_statement( session["StartSession"]["SessionToken"], transaction["StartTransaction"]["TransactionId"], "SELECT * FROM Vehicle", [] ) |> ExAws.request(region: Application.get_env(:mpp, :aws_region))
Actually I get a hashed result back:
{:ok, %{ "ExecuteStatement" => %{ "FirstPage" => %{ "Values" => [ %{ "IonBinary" => "4AEA6u6mgYPeooe+n4NWSU6EVHlwZYRZZWFyhE1ha2WFTW9kZWyFQ29sb3LeuYqOkTFDNFJKRkFHMEZDNjI1Nzk3i4VTZWRhbowiB+ONiE1lcmNlZGVzjodDTEsgMzUwj4VXaGl0ZQ==" }, %{ "IonBinary" => "4AEA6u6mgYPeooe+n4NWSU6EVHlwZYRZZWFyhE1ha2WFTW9kZWyFQ29sb3LetYqOkUtNOFNSREhGNkVVMDc0NzYxi4VTZWRhbowiB9+NhVRlc2xhjodNb2RlbCBTj4RCbHVl" }, %{ "IonBinary" => "4AEA6u6mgYPeooe+n4NWSU6EVHlwZYRZZWFyhE1ha2WFTW9kZWyFQ29sb3LewoqOkTNIR0dLNUc1M0ZNNzYxNzY1i4pNb3RvcmN5Y2xljCIH242GRHVjYXRpjoxNb25zdGVyIDEyMDCPhlllbGxvdw==" }, %{ "IonBinary" => "4AEA6u6mgYPeooe+n4NWSU6EVHlwZYRZZWFyhE1ha2WFTW9kZWyFQ29sb3LesYqOkTFONEFMMTFENzVDMTA5MTUxi4VTZWRhbowiB9uNhEF1ZGmOgkE1j4ZTaWx2ZXI=" }, %{ "IonBinary" => "4AEA6u6mgYPeooe+n4NWSU6EVHlwZYRZZWFyhE1ha2WFTW9kZWyFQ29sb3LesoqOkTFIVkJCQUFOWFdINTQ0MjM3i4RTZW1pjCIH2Y2ERm9yZI6FRiAxNTCPhUJsYWNr" } ] } } }}
But now I am confused. How do I get the result in clear text? So I thought, using the commit_function is necessary and do the following:
ExAws.QLDBSession.commit_transaction( session["StartSession"]["SessionToken"], transaction["StartTransaction"]["TransactionId"], "SELECT * FROM Vehicle", [] ) |> ExAws.request(region: Application.get_env(:mpp, :aws_region))
But then, I get an Erlang/Python error back:
** (ErlangError) Erlang error: {:python, :"builtins.ModuleNotFoundError", 'No module named \'amazon\'', [' File "/Users/gesslbauer/Documents/Webprojects/mpp/_build/dev/lib/ex_aws_qldb/priv/python/qldb_ionhash.py", line 1, in <module>\n from amazon.ion.simpleion import loads, dumps\n', ' File "/Users/gesslbauer/Documents/Webprojects/mpp/_build/dev/lib/erlport/priv/python3/erlport/erlang.py", line 225, in _incoming_call\n f = __import__(mod, {}, {}, [objects[0]])\n', ' File "/Users/gesslbauer/Documents/Webprojects/mpp/_build/dev/lib/erlport/priv/python3/erlport/erlang.py", line 233, in _call_with_error_handler\n function(*args)\n']} (erlport) /Users/gesslbauer/Documents/Webprojects/mpp/deps/erlport/src/erlport.erl:234: :erlport.call/3 (ex_aws_qldb) lib/ex_aws/qldb_session.ex:125: ExAws.QLDBSession.commit_transaction/4 (mpp) lib/mpp/instructions.ex:75: Mpp.Instructions.get_vehicles/0
Expected behavior
Get the the data from "vehicles-registration" in clear text.