PyCharm 2024.2 Help

Databases with basic support

Enable the Database Tools and SQL plugin

This functionality relies on the Database Tools and SQL plugin, which is bundled and enabled in PyCharm by default. If the relevant features are not available, make sure that you did not disable the plugin.

  1. Press Ctrl+Alt+S to open settings and then select Plugins.

  2. Open the Installed tab, find the Database Tools and SQL plugin, and select the checkbox next to the plugin name.

To create a data source, you need a JDBC driver. There are two types of drivers in PyCharm: with Complete Support and with Basic Support. You can see a list of database vendors with complete and basic support on the Drivers tab in the Data Sources and Drivers dialog. Also, note that user-created drivers are considered as drivers with basic support.

  • Complete Support includes such features as enhanced code completion and better retrieval of database objects (introspection). For example, with complete support, you will see the following objects in the corresponding databases: user-defined types in Apache Cassandra, macros in Apache Hive, extensions in PostgreSQL. Also, all inspections, quick-fixes, and other coding assistance features are available for databases with the complete support.

  • Basic Support provides a code highlighting, and it also displays the objects retrieved by the JDBC driver. PyCharm uses JDBC metadata for database introspection and the SQL 2016 dialect for code highlighting. No errors are detected and highlighted.

    The introspection with JDBC metadata means that some specific database objects will not appear in the database tree view. Code completion will not include objects that were not retrieved during introspection.

Drivers with complete and basic support

Basic support is provided for the following database vendors:

  • AWS Athena

  • Apache Ignite

  • Apache Spark

  • DuckDB

  • Elasticsearch

  • Firebird

  • Google Cloud Spanner

  • Informix

  • InterSystems IRIS

  • Mimer SQL

  • OpenEdge

  • Phoenix

  • Presto

  • SAP HANA

  • SingleStore

  • Tarantool

  • Teradata

  • TiDB

  • Tibero

  • Trino

  • YugabyteDB

Creating data sources from drivers with basic support

There are two ways to create data sources from drivers with basic support.

  • Using the Other submenu

  • Using user driver files

Using the Other submenu

  1. Open data source properties. You can open data source properties by using one of the following options:

    • In the Database tool window ( View | Tool Windows | Database) , click the Data Source Properties icon The Data Source Properties icon.

    • Press Shift+Enter.

  2. In the Data Sources and Drivers dialog, you can use Data Sources and Drivers tabs to create a data source.

    • Data Sources: click the Add icon (The Add icon) and navigate to Other. In this submenu, select the driver that you want to use for the data source creation.

    • Drivers: click the Drivers tab and select the necessary driver. In the settings of this driver, click Create Data Source.

  3. Specify the database connection details. Alternatively, paste the JDBC URL in the URL field.

    To delete a password, right-click the Password field and select Set Empty.

    General tab of the Data Sources and Drivers dialog

    For the reference information about connection settings (for example, Host, Port, and so on) on the General and other tabs of Data Sources and Drivers dialog (Shift+Enter) , see Data Sources.

  4. Check if there is a Download missing driver files link at the bottom of the connection settings area. Click this link to download drivers that are required to interact with a database. For a direct download link, refer to the JetBrains JDBC drivers page.

    Location for the downloaded JDBC drivers is the PyCharm configuration directory.

    The Download missing driver files link

    You can also use your drivers for the database instead of the provided ones. For more information about connecting to a database with your driver, refer to Add a user driver to an existing connection.

    If there is no Download missing driver files link, then you already have the required drivers.

  5. Ensure that the connection to the database can be established using the provided details. To do that, click the Test Connection link at the bottom of the connection details area.

    Test Connection link

    In case of any connection issues, refer to the Cannot connect to a database page.

  6. Click OK to create the data source.

Drivers that have basic support

Using user driver files

  1. Open data source properties. You can open data source properties by using one of the following options:

    • In the Database tool window ( View | Tool Windows | Database) , click the Data Source Properties icon The Data Source Properties icon.

    • Press Shift+Enter.

  2. In the Data Sources and Drivers dialog, ensure that you are on the Drivers tab.

  3. In the Data Sources and Drivers dialog, click the Add icon (The Add icon).

  4. In the Name field, type the name of the driver.

  5. In the Driver Files pane, click the Add icon (The Add icon) and select Custom JARs.

  6. Navigate to the JAR file of the JDBC driver, select it, and click OK.

  7. In the Class field, specify the value that you want to use for the driver.

  8. Click Apply.

  9. To create a data source from the driver's dialog, click Create Data Source.

Library paths for user drivers

To work properly, some JDBC drivers require a path to library files along with the driver.

For example, to determine if the application should operate in the Instant Client mode, Oracle Instant Client (OCI) applications look for library files in the runtime library search path (LD_LIBRARY_PATH on Linux or PATH on Windows). You can set these paths in the Data Sources and Drivers dialog.

Adding library paths

  1. Open data source properties. You can open data source properties by using one of the following options:

    • In the Database tool window ( View | Tool Windows | Database) , click the Data Source Properties icon The Data Source Properties icon.

    • Press Shift+Enter.

  2. In the Data Sources and Drivers dialog, click the driver entry to which you want to add a path to library files.

  3. (Optional) Add a driver for which you want to add library files. If the existing driver does not meet the requirements, replace the existing driver. To delete the existing driver entry, select the driver and click Remove. For more information about adding a driver, refer to create a connection to a database with a JDBC driver.

  4. In the Driver files pane, click the Add icon (The Add icon) and select Native Library Path.

  5. Navigate to the folder with library files. Ensure that the driver version corresponds to the version of these library files. For example, if you use the driver version 19.6, the attached library files must also have the 19.6 version.

    Working with the Native Library Path

Productivity tips

Create a data source from the JDBC URL

  1. To connect to the database, create a data source that will store your connection details. You can do this using one of the following ways:

    • In the main menu, go to File | New | Data Source from URL.

    • In the Database tool window ( View | Tool Windows | Database) , click the New icon (the New icon) in the toolbar. Navigate to Data Source from URL.

  2. In the URL field, paste the JDBC URL.

  3. From the Driver list, select the necessary driver for the data source.

    Create a data source from the JDBC URL
  4. In the Data Sources and Drivers dialog, enter credentials.

  5. Ensure that the connection to the database can be established using the provided details. To do that, click the Test Connection link at the bottom of the connection details area.

    Test Connection link

    In case of any connection issues, refer to the Cannot connect to a database page.

  6. Click OK to create the data source.

  7. Find your new data source in the Database tool window (⌘ 1) .

    • For more information about the Database tool window, see the corresponding reference topic.

    • For more information about working with database objects in PyCharm, refer to Database objects.

    • To write and run queries, open the default query console by clicking the data source and pressing F4.

    • To view and edit data of a database object, open Data editor and viewer by double-clicking the object.

Last modified: 11 October 2024