---
title: "Discussion on \"Securely Managing Database Credentials in Python with dotenv\" | Hashnode"
description: "Discussion on \"Securely Managing Database Credentials in Python with dotenv\". Manage sensitive credential securely using python-dotenv in database connection strings"
url: "https://hashnode.com/posts/securely-managing-database-credentials-in-python-with-dotenv/674b0d72215438057075fc8f"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Securely Managing Database Credentials in Python with dotenv](https://rhodalee.hashnode.dev/securely-managing-database-credentials-in-python-with-dotenv?utm_source=hashnode&utm_medium=feed)

Manage sensitive credential securely using python-dotenv in database connection strings

Nov 30, 2024 · 6 min read · rhodalee.hashnode.dev  
Updated Jan 1, 2025  
Read the article

-   [#python](https://hashnode.com/tag/python)
-   [#databases](https://hashnode.com/tag/databases)
-   [#dotenv](https://hashnode.com/tag/dotenv)
-   [#python-dotenv](https://hashnode.com/tag/python-dotenv)
-   [#mysql](https://hashnode.com/tag/mysql)
-   [#sqlalchemy](https://hashnode.com/tag/sqlalchemy)

## Written by

[Rhoda Oduro-Nyarko](https://hashnode.com/@rhodalee)

@rhodalee

  
[View profile](https://hashnode.com/@rhodalee)

Python Development | Backend | Data Analysis | Data Science |

The more I learn the more I realize how much I don't know!

## Responses 2

Markdown supported · ⌘↵ to post

[Samuel Amankwah Donkor](https://hashnode.com/@samadon)

[Jan 2, 2025](https://hashnode.com/posts/securely-managing-database-credentials-in-python-with-dotenv/674b0d72215438057075fc8f/comment/67762736c890407fc3a702a1)

Great guide on dotenv, [Rhoda Oduro-Nyarko](https://hashnode.com/@rhodalee)! Thanks for sharing.

[PRECIOUS TOGODUI](https://hashnode.com/@precioustogodui)

[Dec 2, 2024](https://hashnode.com/posts/securely-managing-database-credentials-in-python-with-dotenv/674b0d72215438057075fc8f/comment/674d83bd4732760266755c74)

Thank you! This was very helpful and easy to follow. I have a question though. Erm, so what happens when we print the database username, password and database name? What is it supposed to print out? Is it supposed to print out our database username, password and database name or it's to print out 'None'.

[Rhoda Oduro-Nyarko](https://hashnode.com/@rhodalee)

[Dec 2, 2024](https://hashnode.com/posts/securely-managing-database-credentials-in-python-with-dotenv/674b0d72215438057075fc8f/comment/674d83bd4732760266755c74#reply-674d86a284d3caecd579815e)

We are printing just to test if the environment variables have been properly loaded into our config.py file It is supposed to print your database username, password and the database name. If it prints none then that variable hasn't loaded correctly. In that case check both .env and config.py files and be sure your code is correctly inputted.
