Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script - No connection to insert data #171

Closed
gilbertojuniortelgo opened this issue Feb 7, 2017 · 8 comments
Closed

Script - No connection to insert data #171

gilbertojuniortelgo opened this issue Feb 7, 2017 · 8 comments

Comments

@gilbertojuniortelgo
Copy link

I am currently creating a .exs script,
To communicate with Mysql.
The following script below.

ExUnit.start

defmodule PreparedQueryTest do
use ExUnit.Case, async: true
import Mariaex.TestHelper
setup do
{:ok, p} = Mariaex.Connection.start_link(username: "user", password: "password", database: "elixir_1", hostname: "192.168.10.90")
Mariaex.query(p, "INSERT INTO elixir_1.formulario VALUES('value1', 'value2', 'value3', 'value4');")
end

end

Error:

(CompileError) PROJECT_1/myapp/test/home.exs:13: module Mariaex.TestHelper is not loaded and could not be found

How to solve?
Note: The shell works perfectly the command {:ok, p} = Mariaex.Connection.start_link(username: "user", password: "password", database: "elixir_1", hostname: "192.168.10.90")

@NobbZ
Copy link

NobbZ commented Feb 8, 2017

Neither your App, nor its dependencies get started when in test env, so you have to do it yourself. In your testhelper it should be sufficient to add `Application.ensure_started(:mariaex).

I do not know this library though but have come because of your post on the elixirforum: https://elixirforum.com/t/problem-script-creation/3602

@gilbertojuniortelgo
Copy link
Author

unsuccessfully.

@NobbZ
Copy link

NobbZ commented Feb 8, 2017

I took a closer look. There is no mariaex.testhelper in this application. Have you created it on your own? If not it can't work...

@gilbertojuniortelgo
Copy link
Author

In fact,
I took a look at the script https://github.com/xerions/mariaex/blob/master/test/query_test.exs

I took as an example to create my own script.

Steps I've taken
1 - I added the following line at the mix.exs

Def deps
   [{:mariaex, "> = 0.7.3"}]
End

2 - After "mix.deps.get"
3 - I played my script into the test folder
4 - I ran the "mix test" command
5 - I tried to run the script with the command "iex script.exs"
6 - He gives me this error
(CompileError) PROJECT_1 / myapp / test / home.exs: 13: module Mariaex.TestHelper is not loaded and could not be found

I did not do anything else.
What do I need to do to continue?

I'm new to Elixir

@NobbZ
Copy link

NobbZ commented Feb 8, 2017

Mariaex.TestHelper is a module private to this applications test environment, used only for testing this application, you do not need it. Replace that with an import for your applications *.TestHelper

@gilbertojuniortelgo
Copy link
Author

Would you have any such scripts?

For example.

@NobbZ
Copy link

NobbZ commented Feb 8, 2017

A TestHelper you mean? It should have been generated when running mix new for that project. Since your questions are not related to mariaex in any kind but about elixir and its tooling in general, I would be very fine if you could close here and continue at elixirforum.com

@gilbertojuniortelgo
Copy link
Author

Thank you very much for your help.
I'm having a hard time connecting to the MySQL database.
But I will be studying each module even more.
I'll close it here, and pass directly there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants