# Configurate database connection (APP created with Genie)

**URL:** <https://discourse.julialang.org/t/configurate-database-connection-app-created-with-genie/71918>\
**Category:** General Usage\
**Tags:** question, mysql, genie\
**Created:** [November 22, 2021, 9:51pm UTC](https://discourse.julialang.org/t/configurate-database-connection-app-created-with-genie/71918 "2021-11-22T21:51:53Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![fms-1988](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fms-1988/32/20275_2.png) [@fms-1988](https://discourse.julialang.org/u/fms-1988)\
**Post date:** [November 22, 2021, 9:51pm UTC](https://discourse.julialang.org/t/configurate-database-connection-app-created-with-genie/71918/1 "2021-11-22T21:51:53Z")

</div>

I bootstrapped an APP using Genie.  
I chose the MySQL DB.  
I edited the db/connection.yml file as required:

```julia
env: ENV["GENIE_ENV"]

  dev:
  adapter: MySQL
  database: db
  host: localhost
  username: felipe 
  password: **********
  port: 3306
  config: 

```

but when I try to manually load the database configuration `include(joinpath("config","initializers","searchlight.jl"))` I have an error:

```julia
┌ Error: SystemError("opening file \"db/connection.yml\"", 2, nothing)
└ @ Main /home/felipe/Documents/julia/Genie/watchtonight/config/initializers/searchlight.jl:11

```

What is wrong with my configuration?

---

<div class="post-metadata">

**Author:** ![goerch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goerch/32/29122_2.png) [@goerch](https://discourse.julialang.org/u/goerch)\
**Post date:** [November 23, 2021, 3:11pm UTC](https://discourse.julialang.org/t/configurate-database-connection-app-created-with-genie/71918/2 "2021-11-23T15:11:30Z")

</div>

What does `pwd()` show you?

---

<div class="post-metadata">

**Author:** ![fms-1988](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fms-1988/32/20275_2.png) [@fms-1988](https://discourse.julialang.org/u/fms-1988)\
**Post date:** [November 23, 2021, 5:18pm UTC](https://discourse.julialang.org/t/configurate-database-connection-app-created-with-genie/71918/3 "2021-11-23T17:18:18Z")

</div>

show: “/home/felipe/Documents/julia/Genie”

then I tried:

```julia
include("/home/felipe/Documents/julia/Genie/watchtonight/config/initializers/searchlight.jl")

```

then, the same error occurred.

---

<div class="post-metadata">

**Author:** ![goerch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goerch/32/29122_2.png) [@goerch](https://discourse.julialang.org/u/goerch)\
**Post date:** [November 23, 2021, 5:22pm UTC](https://discourse.julialang.org/t/configurate-database-connection-app-created-with-genie/71918/4 "2021-11-23T17:22:26Z")

</div>

But you see `watchtonight` was missing in your first attempt? The error

```julia
Error: SystemError("opening file \"db/connection.yml\"", 2, nothing)

```

furthermore indicates a sub directory named `db` is still missing?

---

<div class="post-metadata">

**Author:** ![fms-1988](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fms-1988/32/20275_2.png) [@fms-1988](https://discourse.julialang.org/u/fms-1988)\
**Post date:** [November 23, 2021, 5:42pm UTC](https://discourse.julialang.org/t/configurate-database-connection-app-created-with-genie/71918/5 "2021-11-23T17:42:32Z")

</div>

The sub directory `db` is not missing.  
When I call the file `.../searchlight.jl` it call another file named `.../db/connection.yml`.

---

<div class="post-metadata">

**Author:** ![goerch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goerch/32/29122_2.png) [@goerch](https://discourse.julialang.org/u/goerch)\
**Post date:** [November 23, 2021, 5:54pm UTC](https://discourse.julialang.org/t/configurate-database-connection-app-created-with-genie/71918/6 "2021-11-23T17:54:49Z")

</div>

Oh, OK. Maybe we should look into `searchlight.jl` then?

---

<div class="post-metadata">

**Author:** ![fms-1988](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fms-1988/32/20275_2.png) [@fms-1988](https://discourse.julialang.org/u/fms-1988)\
**Post date:** [November 23, 2021, 7:03pm UTC](https://discourse.julialang.org/t/configurate-database-connection-app-created-with-genie/71918/7 "2021-11-23T19:03:59Z")

</div>

the content of the file `searchlight.jl ` is:

```julia
using SearchLight

try
  SearchLight.Configuration.load()

  if SearchLight.config.db_config_settings["adapter"] !== nothing
    eval(Meta.parse("using SearchLight$(SearchLight.config.db_config_settings["adapter"])"))
    SearchLight.connect()
  end
catch ex
  @error ex
end

```

---

<div class="post-metadata">

**Author:** ![goerch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goerch/32/29122_2.png) [@goerch](https://discourse.julialang.org/u/goerch)\
**Post date:** [November 23, 2021, 7:32pm UTC](https://discourse.julialang.org/t/configurate-database-connection-app-created-with-genie/71918/8 "2021-11-23T19:32:27Z")

</div>

Thanks. I’m sorry, but I can’t imagine the environment this `eval` is running in… ;(

---

<div class="post-metadata">

**Author:** ![fms-1988](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fms-1988/32/20275_2.png) [@fms-1988](https://discourse.julialang.org/u/fms-1988)\
**Post date:** [November 23, 2021, 9:05pm UTC](https://discourse.julialang.org/t/configurate-database-connection-app-created-with-genie/71918/9 "2021-11-23T21:05:50Z")

</div>

@goerch, i solved the problem.  
I bootstrapped the APP again and changed `localhost` to `127.0.0.1`

```julia
env: ENV["GENIE_ENV"]

dev:
  adapter: MySQL
  database: db
  host: 127.0.0.1
  username: felipe 
  password: ********** 
  port: 3306
  config:

```

Thank you for your attention

---

<div class="post-metadata">

**Author:** ![goerch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goerch/32/29122_2.png) [@goerch](https://discourse.julialang.org/u/goerch)\
**Post date:** [November 23, 2021, 9:07pm UTC](https://discourse.julialang.org/t/configurate-database-connection-app-created-with-genie/71918/10 "2021-11-23T21:07:02Z")

</div>

Thanks for your feedback!
