PyCharm Help

Data Sources

PyCharm does not enable you to create databases, but provides facilities to manage and query them. Once you are granted access to a certain database, you can configure one or more data sources within PyCharm that reflect the structure of the database and store the database access credentials. Based on this information, PyCharm establishes connection to the database and provides the ability to retrieve or change information contained therein.

In this section:

Data source scopes

There are the data sources that are available in all of your projects. Such data sources are said to have the IDE scope. Others, ones with the project scope, are available in only one of your projects.

Data source types

PyCharm supports data sources of the following types:

  • DB data sources (also called database connections), which correspond to real databases.
  • DDL data sources, which represent the necessary data structures and act as stub databases, the databases without any data. For this data source type you should have one or more SQL DDL files representing the required data structures available in your project directory (or one of its subdirectories). Also note that a particular SQL dialect should be set for all those files (or the directories containing those files).

DB data sources can have the IDE or the project scope; DDL data sources exist only at the project level.

Database connections

PyCharm connects to the necessary databases automatically, when needed. This happens, for example, when you execute an SQL statement in the database console or open a table in the Table Editor.

Similarly, all database connections are automatically terminated when you exit the IDE.

The names of the data sources with open database connections are shown in the Database tool window in bold.

If necessary, you can close all unnecessary database connections manually. To do that:

  1. In the Database tool window, select the corresponding data source or data sources. (To select more than one data source, use mouse clicks in combination with the Ctrl key.)
  2. Do one of the following:
    • Click stop on the toolbar.
    • Select Disconnect from the context menu.
    • Press Ctrl+F2.

Overview of the features

Here is a very brief overview of PyCharm features related to working with data sources:

See Also

Last modified: 15 May 2015