Where to set the DATABASE_URL environment variable on Heroku

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Where to set the DATABASE_URL environment variable on Heroku

Tim Johnson-18
Despite the voluminous Heroku documentation I am unable to establish
where to initialize the DATABASE_URL that would establish credentials
for my deployed database.

Heroku's documentation uses the following example

DATABASE_URL=$(heroku config:get HEROKU_POSTGRESQL_TIMS_URL -a timsapp)

But I am not clear where this initialization code should live

would it be in the procfile? If so, what process should I use. Release?
Worker?

OR

Would it be in an .env file?

Using django 2.1.5, python 3.7

examples welcome :)

thanks

--
Tim
tj49.com

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a02698e8-e71a-5d42-728d-4c6d012bbb84%40akwebsoft.com.
Reply | Threaded
Open this post in threaded view
|

Re: Where to set the DATABASE_URL environment variable on Heroku

Jorge Gimeno

On Fri, Dec 6, 2019 at 5:40 PM Tim Johnson <[hidden email]> wrote:
Despite the voluminous Heroku documentation I am unable to establish
where to initialize the DATABASE_URL that would establish credentials
for my deployed database.

Heroku's documentation uses the following example

DATABASE_URL=$(heroku config:get HEROKU_POSTGRESQL_TIMS_URL -a timsapp)

But I am not clear where this initialization code should live

would it be in the procfile? If so, what process should I use. Release?
Worker?

OR

Would it be in an .env file?

Using django 2.1.5, python 3.7

examples welcome :)

thanks

--
Tim
tj49.com

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a02698e8-e71a-5d42-728d-4c6d012bbb84%40akwebsoft.com.
 
I believe DATABASE_URL is set on Heroku itself as a configuration variable.  If you provision the database in Heroku, it will be set for you.  See here:  https://devcenter.heroku.com/articles/heroku-postgresql#provisioning-heroku-postgres

-Jorge
 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CANfN%3DK9EOSQG-jmd7FJD_hpEaqGp8AbChSgnE-pMgBhued13og%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Where to set the DATABASE_URL environment variable on Heroku

Tim Johnson-18


On 12/6/19 9:09 PM, Jorge Gimeno wrote:

On Fri, Dec 6, 2019 at 5:40 PM Tim Johnson <[hidden email]> wrote:
Despite the voluminous Heroku documentation I am unable to establish
where to initialize the DATABASE_URL that would establish credentials
for my deployed database.

Heroku's documentation uses the following example

DATABASE_URL=$(heroku config:get HEROKU_POSTGRESQL_TIMS_URL -a timsapp)

But I am not clear where this initialization code should live

would it be in the procfile? If so, what process should I use. Release?
Worker?

OR

Would it be in an .env file?
... snip ...
I believe DATABASE_URL is set on Heroku itself as a configuration variable.  If you provision the database in Heroku, it will be set for you.  See here:  https://devcenter.heroku.com/articles/heroku-postgresql#provisioning-heroku-postgres

Thank you Jorge, I have read that section too:

The following is highlighted as a warning on that:

"""

The value of your app’s DATABASE_URL config var might change at any time.

You should not rely on this value either inside or outside your Heroku app.

"""

that is precisely why I have asked this question.

more discussion of this issue is found at https://devcenter.heroku.com/articles/connecting-to-heroku-postgres-databases-from-outside-of-heroku

and a search for "DATABASE_URL=$("  will give an example of how to set DATABASE_URL from the Heroku command line.

That approach begs for a script but I am unsure of what script file to use. .env or Procfile or some other.

Thanks again Jorge

-- 
Tim
tj49.com

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/14cf27a4-eb56-5925-fcf8-50ca3344f9e8%40akwebsoft.com.
Reply | Threaded
Open this post in threaded view
|

Re: Where to set the DATABASE_URL environment variable on Heroku

Dvs Khamele
Hi do you hire contract based python/django freelancer?
 I can help you in this 
Best Regards, 
Divyesh Khamele

On Sat, 7 Dec 2019 at 21:53, Tim Johnson <[hidden email]> wrote:


On 12/6/19 9:09 PM, Jorge Gimeno wrote:

On Fri, Dec 6, 2019 at 5:40 PM Tim Johnson <[hidden email]> wrote:
Despite the voluminous Heroku documentation I am unable to establish
where to initialize the DATABASE_URL that would establish credentials
for my deployed database.

Heroku's documentation uses the following example

DATABASE_URL=$(heroku config:get HEROKU_POSTGRESQL_TIMS_URL -a timsapp)

But I am not clear where this initialization code should live

would it be in the procfile? If so, what process should I use. Release?
Worker?

OR

Would it be in an .env file?
... snip ...
I believe DATABASE_URL is set on Heroku itself as a configuration variable.  If you provision the database in Heroku, it will be set for you.  See here:  https://devcenter.heroku.com/articles/heroku-postgresql#provisioning-heroku-postgres

Thank you Jorge, I have read that section too:

The following is highlighted as a warning on that:

"""

The value of your app’s DATABASE_URL config var might change at any time.

You should not rely on this value either inside or outside your Heroku app.

"""

that is precisely why I have asked this question.

more discussion of this issue is found at https://devcenter.heroku.com/articles/connecting-to-heroku-postgres-databases-from-outside-of-heroku

and a search for "DATABASE_URL=$("  will give an example of how to set DATABASE_URL from the Heroku command line.

That approach begs for a script but I am unsure of what script file to use. .env or Procfile or some other.

Thanks again Jorge

-- 
Tim
tj49.com

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/14cf27a4-eb56-5925-fcf8-50ca3344f9e8%40akwebsoft.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAH9mneXrpBWTKUQpNNvQNrRkuh0q9tKbLC18kvVCEUFpXzcuCw%40mail.gmail.com.