PyCharm 4.0.0 Web Help

Some features described here are available in the Professional edition only.

You can create a data source of the required type from scratch or by importing the files that contain the necessary database definitions (e.g. connection settings).

PyCharm recognizes the databases produced by the Django applications, and imports them to data sources.

DDL data sources and DB data sources for H2 and SQLite can be created by means of drag and drop.

To import a DB data source
  1. Open the Database tool window.
  2. Do one of the following:
    • Click add on the toolbar and select Import from sources.
    • Right-click the area under the toolbar or any of the existing data sources, point to New and click Import from sources.
    • Press Alt+InsertAlt+InsertAlt+InsertAlt+InsertAlt+InsertAlt+InsertAlt+Insert or Ctrl+NAlt+Insert⌘ N or Control EnterControl N or Control Enter⌘ N or Control Enter and select Import from sources.
  3. The Data Sources and Drivers dialog opens. The names of candidate data sources are shown in the left-hand pane under Data Sources in green. The names of the configuration files in which database connection settings were found are shown in square brackets. The data source settings are shown in the right-hand part of the dialog.

    Edit the data source settings as necessary. Download the database driver files if they are missing.

  4. Click Test Connection to make sure that PyCharm can properly communicate with the database.
  5. In the Connection successful message box, click OK.
  6. Click OK in the Data Sources and Drivers dialog.
  7. In the Database tool window, click refresh on the toolbar. (Alternatively, select Synchronize from the context menu, or press Ctrl+Alt+YCtrl+Alt+YCtrl+Alt+YCtrl+Alt+YCtrl+Alt+YCtrl+Alt+YCtrl+Alt+YCtrl+Alt+YAlt ⌘ YAlt ⌘ YAlt ⌘ Y.)
To create a DDL data source by means of drag and drop

You can create DDL data sources by dragging DDL SQL files to the Database tool window. The files can be dragged from the Project tool window, or from your file manager (e.g. Explorer or Finder).

  1. If the necessary DDL SQL files are in your project folder, open the Project tool window (e.g. Alt+1Alt+1Alt+1Alt+1Alt+1Alt+1Ctrl+1, Ctrl+2, Ctrl+3 or Alt+1Alt+1⌘ 1⌘ 1⌘ 1). Otherwise, open your file manager.
  2. Open the Database tool window.
  3. If you already have one or more DDL data sources defined but there are no DB data sources, expand one of the data source nodes in the Database tool window.
  4. Select the file or files of interest in the Project tool window, or in your file manager.
  5. Drag the selected file or files into the Database tool window. For a new data source to be created, the red border, when dropping the file or files, should surround most of the window area (rather than one of the existing data sources).

    DBNewDDLByDragAndDrop

To create a DB data source for H2 or SQLite by means of drag and drop

If you have H2 or SQLite database files available locally, you can create DB data sources for them by dragging the files to the Database tool window. The files can be dragged from the Project tool window, or from your file manager (e.g. Explorer or Finder).

  1. If the database files are in your project folder, open the Project tool window (e.g. Alt+1Alt+1Alt+1Alt+1Alt+1Alt+1Ctrl+1, Ctrl+2, Ctrl+3 or Alt+1Alt+1⌘ 1⌘ 1⌘ 1). Otherwise, open your file manager.
  2. Open the Database tool window.
  3. Select the file or files of interest in the Project tool window, or in your file manager.
  4. Drag the selected file or files into the Database tool window. (For each of the files a separate data source will be created.)

    DBNewDBDragAndDrop

  5. If you don't have the necessary database driver files yet, you can download them now. Click properties on the toolbar of the Database tool window. (Alternatively, select Properties from the context menu, or press F4F4F4F4F4F4F4F12 or Ctrl+Shift+E⌘ Down or F4F4F3.)
  6. In the lower part of the Data Sources and Drivers dialog that opens, within the line that starts with Driver files missing, click the Download link.
  7. Click Test Connection to make sure that PyCharm can properly communicate with the database.
  8. In the Connection successful message box, click OK.
  9. Click OK in the Data Sources and Drivers dialog.
  10. In the Database tool window, click refresh on the toolbar. (Alternatively, select Synchronize from the context menu, or press Ctrl+Alt+YCtrl+Alt+YCtrl+Alt+YCtrl+Alt+YCtrl+Alt+YCtrl+Alt+YCtrl+Alt+YCtrl+Alt+YAlt ⌘ YAlt ⌘ YAlt ⌘ Y.)
To create a DB or DDL data source from scratch
  1. Open the Database tool window.
  2. Do one of the following:
    • Click add on the toolbar.
    • Right-click the area under the toolbar or any of the existing data sources, and select New.
    • Press Alt+InsertAlt+InsertAlt+InsertAlt+InsertAlt+InsertAlt+InsertAlt+Insert or Ctrl+NAlt+Insert⌘ N or Control EnterControl N or Control Enter⌘ N or Control Enter.
  3. Select:

See Also

Concepts:

Procedures:

Reference:

Web Resources: