Click to download the latest version of PyCharm

When you create a database connection, PyCharm connects to the database to automatically receive database objects. The connection is then closed. The name of the data source that interacts with the database is displayed in the Database tool window with a small green circle.

To close the database connection, select a data source and click the Disconnect button on the toolbar. Alternatively, select a data source and press Ctrl+F2.

Password storage options

You can select the following options to store passwords:

  • Never: Prompts for a password each time a connection is made to the database.

  • Before restarting: Save only the current PyCharm running password. If you exit PyCharm and turn it on again, you must provide the password again.

  • For sessions: Save the password only for the current connection session with the database (until disconnecting from the database). You can do this by pressing the Disconnect icon () or terminate the connection with Ctrl+F2.

  • Forever: Passwords are stored in PyCharm. The next time PyCharm is turned on, there is no need to provide a password.

JDBC driver

Change the driver version

  1. In Tool window “Database” (” the View | Tool Windows | Database “), click on the “Data Source Properties” icon.

  2. In the Data Sources and Drivers dialog box, select the Data source in which you want to change the Driver, and then click the Driver link in the Data source Settings.

    Some data sources have a drop-down list of different versions of drivers (for example, MySQL). In these cases, select Go to Driver from the list.

  3. In the Driver Files pane, click the version number, and then select the desired Driver version.

Add a JDBC driver to an existing connection

  1. In Tool window “Database” (” the View | Tool Windows | Database “), click on the “Data Source Properties” icon.

  2. In the Data Sources and Drivers dialog box, select the Data source in which you want to change the Driver, and then click the Driver link in the Data source Settings.

  3. Click the provided driver entry, and then click Remove.

    To undo your changes, click Reset in the upper right of the window. Or, click the add button to select after Provided Driver | < database_name > | < driver_version >

  4. In the Driver Files pane, click the Add icon, and then select Custom JARS.

  5. Navigate to the JAR file for the JDBC driver, select it, and click OK.

  6. In the Class field, specify the value to be used for the driver.

  7. Hit Apply.

Add ICONS to the user driver

You can change the default icon for the user driver.

  1. In Tool window “Database” (” the View | Tool Windows | Database “), click on the “Data Source Properties” icon. Then select the driver you created.

  2. Click the Options TAB and scroll down to the other sections.

  3. From the Icon list, select the icon that you want to assign to the driver.

  4. Click OK.

Connection option

Keep the connection open

You can keep connections to the database active by running keepalive queries after a specified period of time. You can define custom queries for unsupported databases in driver Settings.

  1. In Tool window “Database” (” the View | Tool Windows | Database “), click on the “Data Source Properties” icon.

  2. Select the data source to modify.

  3. On the Options TAB, select the Run Keep-active query every N seconds check box, where NPyCharm will run the keep-active query again after this number of seconds.

To set up custom keepalive queries for drivers, select the required drivers in the Drivers list. Click the Options TAB. In the Keepalive Query field, specify the query that you want to use as a keepalive query.

Disconnect from the database during the specified period of time

You can specify a number of seconds after which PyCharm terminates the connection.

  1. In Tool window “Database” (” the View | Tool Windows | Database “), click on the “Data Source Properties” icon.

  2. Select the data source you want to modify, and then click the Options TAB.

  3. On the Options TAB, select the automatic Disconnection after N seconds check box, where NPyCharm is the number of seconds that passed to terminate the connection.

Run predefined queries when establishing a connection

You can run predefined queries each time a connection is established.

  1. In Tool window “Database” (” the View | Tool Windows | Database “), click on the “Data Source Properties” icon.

  2. Select the data source to modify.

  3. In the Startup Script field on the Options TAB, specify the query that you plan to run on a connection to the database.

Refreshing the Database Status

If someone changes remote database data or views, the local view of the database may be different from the actual state of the database.

  • To automatically synchronize database state,

    In Tool window “Database” (” the View | Tool Windows | Database “), click on the “Data Source Properties” icon. Then select the data source you want to change. On the Options TAB, select the Automatic Synchronization check box.

    If remove the automatic synchronization checkbox, only when you click on the refresh icon or on time, the Database Tool window (” View | Tool Windows | Database “) in the data source View will sync with the actual status of Database.

To be continued …………

Download and experience PyCharm now!