Global and Local Data Sources
PyCharm distinguishes between Global and Local data sources.
- Global data sources are available in all projects in your workspace.
- Local data sources are available in one specific project only.
Types of Data Sources
PyCharm supports data sources of the following types:
- DB data sources, which correspond to the existing databases the application you are developing will interact with.
- 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 DDL files (SQL file type) 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 be both global and local; DDL data sources can be configured only at the project level.
PyCharm establishes a database connection between a data source and the corresponding database automatically, the first time it needs to execute a query. A database connection is displayed in the Database tool window as a node below the data source via which it is established, and is marked with the icon.
PyCharm closes a connection automatically upon the session termination; alternatively, you can close a database connection manually ( Close Connection in the context menu of a connection (DeleteDeleteDeleteDeleteDelete or Ctrl+DDeleteDeleteDeleteDelete or BackspaceDeleteDelete or Backspace)).
Access to Data Sources
Access to data sources is supported through a variety of PyCharm features and components:
- Support for SQL, which includes syntax and error highlighting, code completion, selection of words and statements, parameter lookup, and refactoring (Introduce constant, for instance).
- The ability to use source files with injected SQL code, with different SQL dialects, configurable at the project, directory, or file level.
- Dedicated Database tool window, where you can configure data sources.
- Database console.
- Configuring DDL data sources based on data structure definition (DDL) files, integration between the data source structure and the corresponding DDL statements in the definition file.
- Generating DDL statements based on the structures of a data source.
- Configuring database management scripts as external tools and running them from within PyCharm.
- The ability to download archives and libraries with driver classes right from PyCharm.