[PYTHON] [Day3] Preparing to connect to the database

January 8, 2021 ← Last time: Generate Day 2 project

Precautionary statement

This article is not a single article. I wrote it as a diary, so I think it will be useful for those who are new to it. If you want to learn Django, we recommend reading it from [Day 1] Django Development Environment.

Introduction

This time I prepared the database. In conclusion, nothing went on ... But what did you get? !!

Database preparation

I could have done it with SQLite, which is included in Django by default, but since the site I was referring to explained MariaDB and PostgreSQL, I tried that setting.

Postgresql connection

First, I tried Postgresql.

$ su postgres
#password input

It seems that this can be done, but I gave up because I did not know the password of postgresql, the password change, and the command su did not understand well.

MariaDB connection

MariaDB seems to be compatible with MySQL, and I used to use MySQL at university, so I felt like I could do it. I didn't have mySQL in the terminal at first, so I started by installing mysql with homebrew. (Code omitted)

So, it seems that you can do it by entering the following code. Enter the root password in {password}.

$ mysql -u root -p{password}

I did it with this,

mysql: [Warning] Using a password on the command line interface can be insecure.

I got an error like that. I think that the root setting is correct because it is set from the directory utility in System Preferences.

After that, as a result of various investigations, it was said that if the password was read from an external file with the vi command, it would not come out, so I tried it, but I could not.

in conclusion

The study time this time was only 2 hours, so I couldn't make it. Looking back at the diary, is there a place where Postgresql can do a little more? I think. If that doesn't work, try SQLite.

← Last time: Generate Day 2 project → Next time: Generate Day 4 application

Recommended Posts

[Day3] Preparing to connect to the database
Connect to utf8mb4 database from python
Preparing to load the original dataset
Connect Sipeed Lichee Zero to the net
[Day 10] Database migration
Connect to mysql
[Introduction to Python3 Day 20] Chapter 9 Unraveling the Web (9.1-9.4)
Connect to the Bitcoin network using pybitcoin tools
Day 66 [Introduction to Kaggle] The easiest Titanic forecast
The road to Pythonista
Connect python to mysql
The road to Djangoist
Connect to the Bitcoin network using pycoin (Python Cryptocoin Utili)
Check when the Docker container does not connect to the Internet
Connect the Jupyter Notebook kernel to Spyder with Jupytext enabled
How to connect the contents of a list into a string
Connect to BigQuery with Python
How to use the generator
Dot according to the image
The road to download Matplotlib
Connect to Postgresql with GO
Connect to sqlite from python
Connect to s3 tokyo region
How to use the decorator
How to increase the axis
How to start the program
The day Chainer runs on GPU CentOS edition (up to CPU)
Try to operate the database using Python's ORM Peewee (August 2019 version)
I want to connect remotely to another computer, and the nautilus command
Raspberry Pi --1 --First time (Connect a temperature sensor to display the temperature)
I want to pass the G test in one month Day 1
Create a function to get the contents of the database in Go