PyCharm 2021.1 Help

Submit changes to a database

A commit ends a transaction and makes all changes available to other users. In PyCharm, you can select how you want to commit transactions: automatically or manually. To change the commit mode, use the Tx drop-down menu on the toolbar.

How changes are committed to a database

The table editor accumulates all the changes that you made. When you press the Submit and Commit button (the Submit button), PyCharm sends these changes to a database. In the database, changes are processed according to the selected commit mode:

  • With Tx:Auto, the database itself commits all the changes.

  • With Tx:Manual, changes are stored in a transaction in the database. When you press Submit and Commit(the Commit button), transactions are committed to the database. When you commit the transaction, the Submit and Commit icon (the Commit button) disables (grays out). It means that all the transactions have been committed.

If the commit mode is set to Auto, each change of values, rows, or columns is implicitly committed and cannot be rolled back. In the Auto commit mode, Submit and Commit The Submit and Commit button and Rollback The Rollback button buttons are disabled.

If the commit mode is set to Manual, you can explicitly commit or roll back the submitted changes by clicking Submit and Commit The Commit button or Rollback The Rollback button buttons. To submit changes to a database, click the Submit button The Submit button.

The Tx switch can also be used for selecting the isolation level for the transactions.

Change the transaction level

Submit changes manually

By default, changes in tables are not submitted automatically. At first, you make changes in your local copy of the table, then you need to submit all changes to a database.

  • To submit changes to a database, click the Submit icon (The Submit icon), or press Ctrl+Enter.

Submit changes automatically

By default, changes are not submitted to a database unless you press the Submit icon The Submit icon, or press Ctrl+Enter. You can enable the Submit changes immediately option to submit your changes automatically.

  1. In settings Ctrl+Alt+S, navigate to Tools | Database | Data Views.

  2. Select Submit changes immediately in the Data Modification.

  3. Click OK.

Select the default transaction mode for a data source

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

  2. In the list of created data sources, click the data source that you want to modify.

  3. Click the Options tab.

  4. From the Transaction control list, select the default transaction mode for the selected data source.

    The selected transaction control is applied for new query consoles.

    default transaction mode for a data source

Revert changes

Before you submit the changes, you can revert them.

The scope of the revert command is defined by the current selection in a table: the command is applied only to the changes within the selection. So you can revert an individual change, a group of changes or all the changes. If nothing is currently selected, the revert command is applied to the whole table.

  • To revert non-submitted changes, select and right-click a cell or a number of cells. Select Revert Selected Ctrl+Alt+Z.

Resolving conflicts when submitting changes

It might happen that someone has changed the piece of code that you have been editing. In this case, when you try to submit your code to a database, PyCharm displays a notification that there is a conflict and you can resolve it by using a three-way merge.

  1. Click Merge.

  2. In the diff dialog, review your local changes and changes that were received from a server.

    Use the Ignore(the Ignore button) button to reject the change. Or, Accept(the Accept button or the Accept button) buttons to apply the change from the left or right pane. The middle pane shows the result of the merge operation.

  3. Click Save changes and finish merging.

    Resolving conflicts when submitting changes

Productivity tips

Display a warning when you edit an outdated piece of DDL code

To ensure that you are not deleting someone's work by submitting an outdated object, turn the Warn when editing outdated DDL option on.

  1. In the Database tool window (View | Tool Windows | Database), right-click a data source and select Properties.

  2. In the Data Sources and Drivers dialog, click the Options tab.

  3. In the Introspection section, select the Warn when editing outdated DDL checkbox.

    Display a warning when you edit an outdated piece of DDL code
Last modified: 08 March 2021