PyCharm supports interface support with various types of databases. Once a user grants access to the created database, it provides schema diagram of the database with SQL writing tools which provide code completion. In this chapter, we will focus on MySQL database connectivity which will involve following steps.
It is important to keep a note that PyCharm supports a wide variety of database connectivity.
Open the database tool window View -> Tool Windows -> Database> and open the dialog called Data Sources and Dialog.
Now, select MySQL database for adding a new data source.
User should download the missing driver files to get proper connectivity with MySQL database.
Now, specify the configuration settings for connectivity to be achieved.
Host − If you database server is on a different computer, replace localhost with the IP address of the server host, e.g. 172.20.240.163.
Port − The default MySQL server port is 3306. If your server uses a different port, specify that port.
User and Password − These are the required credentials.
Always make sure that database connectivity is successful through Test Connection feature.
Testing the connection also involves creating test table through query and executing them. Once the execution is successful, you can drop the database.