For MySQL, this runs the mysql command-line client.For PostgreSQL, this runs the psql command-line client.Runs the command-line client for the database engine specified in your ENGINEsetting, with the connection parameters specified in your USER, PASSWORD, etc., settings. So there are two ways (that I know) to access the psql command. So, for example, when I want to migrate my users app migrations, it looks like this: sudo docker-compose exec web python manage.py migrate users Python Container or Database Container? When I need to use Django’s manage.py, I have to prepend this command: sudo docker-compose exec web. When running management commands with Docker Compose, we have to specify which service we want to run the command. Then to run the local Django server and local PostgreSQL database: sudo docker-compose up -d -build Accessing the Python Container RUN pip install pipenv & pipenv install -systemĬommand: python /code/manage.py runserver 0.0.0.0:8000 That book really helped getting going, but deviating from that path is definitely challenging. Layer that on top of learning Django and you’ve got a clear path to overwhelm.įor context, I can attribute my knowledge of Docker and Docker Compose to Will Vincent from his book “Django for Professionals”. There’s just so much going on behind the scenes it makes reality difficult to comprehend. The Docker Problemĭocker has been great to me, but it’s also been a huge headache. In this post, I’ll talk about how to use psql to view your PostgreSQL database from your Django project. So I ran psql and then… obviously it didn’t work because that would be too easy. I’m starting to realize, however reluctantly, that it’s super important to know how databases work!Īfter seeing a software engineer YouTuber talk through a few of his database tables with some simple commands, I decided that would be a helpful skill. ![]() ![]() As a Django newbie, I’ve found it easy to consider the database stuff “magic” and just leave it alone.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |