PyCharm offers interface support for a number of different kinds of databases. A schema model of the newly constructed database, together with SQL writing tools that offer code completion, is provided once a user gives access to the database. A database may operate locally, remotely, or in the cloud. MySQL,Oracle , PostgreSQL, SQLite, Microsoft SQL Server, MariaDB, Apache Cassandra, and more databases are supported by the plugin. We will concentrate on MySQL database connectivity in this tutorial section.
So far, you have been easily able to use PyCharm functionalities with its community version editor. However, in order to be able to use the Database tools of PyCharm, you must have the Professional version of the PyCharm IDE.
In order to connect your database and use all the SQL functionality here, follow the steps given below.
Step 1: In order to open the, go to View tab and click on Tool Windows and select Database. It will open up the Data Sources and Drivers/ Database dialog box.
Step 2: Select MySQL from the list of available data source options.
Step 3: In case, a dialog box pops up that asks you to download the missing driver files, click on Ok button. You must the drivers that are missing to ensure smooth and proper database connectivity with your SQL database (MySQL).
Step 4: Next step is to define the configuration options needed to accomplish connectivity.
- Substitute the IP address of the server host, such as 172.20.240.163, for localhost if your database server is located on a separate machine.
- Port 3306 is the standard MySQL server port. Indicate the port that your server uses if it uses a different port.
- The necessary credentials are User and Password.
Making and running test tables using queries is another step in testing the connection. You can remove the database after the execution is successful by using the DROP TABLE query as - DROP TABLE *table_name*.