Pycharm 简明教程
Pycharm - Database Tools
PyCharm 支持与各种类型的数据库接口连接。一旦用户授予对已创建数据库的访问权,它就会提供数据库的架构图,其中包含提供代码完成的 SQL 编写工具。在本教程中,我们将重点关注 MySQL 数据库连接,其中涉及以下步骤。
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.
Adding a Data Source
务必记住,PyCharm 支持各种数据库连接。
It is important to keep a note that PyCharm supports a wide variety of database connectivity.
Step 1
打开数据库工具窗口 View → Tool Windows → Database> 并打开名为 Data Sources and Dialog 的对话框。
Open the database tool window View → Tool Windows → Database> and open the dialog called Data Sources and Dialog.

现在,选择 MySQL 数据库以添加新的数据源。
Now, select MySQL database for adding a new data source.
Step 2
用户应下载缺少的驱动程序文件,以与 MySQL database 获得适当的连接。
User should download the missing driver files to get proper connectivity with MySQL database.

Step 3
现在,指定要实现的连接的配置设置。
Now, specify the configuration settings for connectivity to be achieved.
Host − 如果您的数据库服务器位于不同的计算机上,请将 localhost 替换为服务器主机的 IP 地址,例如 172.20.240.163。
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 − MySQL 服务器的默认端口为 3306。如果您的服务器使用不同的端口,请指定该端口。
Port − The default MySQL server port is 3306. If your server uses a different port, specify that port.
User and Password − 这些是必需的凭据。
User and Password − These are the required credentials.
Step 4
始终确保通过 Test Connection 功能成功连接数据库。
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.
