Datalore 2024.5 Help

Export to databases

Use the Export to database cell to append DataFrames to tables attached to your notebooks. Combined with scheduled runs, this will help you have the tables in your project regularly updated with fresh data.

Suppose you retrieved data from an attached database and do some calculations. Now, you want to write the content of the DataFrame containing the results of your calculations to the table. If you set up a schedule for this notebook, you ensure that the table is updated regularly and the other users work with the up-to-date source.

Export a DataFrame to a table

  1. Go to Attached data on the left-hand sidebar.

  2. Click the arrow next to the Connect SQL cell button for the required database and select Export to database cell from the expanded list.

    Selecting Export to database cell

    This will add an Export to database cell to the notebook.

  3. In the Export to database cell, expand the lists in each field to provide the following:

    • Target database connection: the connection with the database containing the required table

    • Source DataFrame: the DataFrame that you want to append

    • Database: the database with the table you want to update

    • Schema: the schema containing the required target table

    • Table: the table that you want to append the source DataFrame to

    Exporting a DataFrame to a database
  4. Run the cell by clicking the Run icon in the upper left corner of the cell.

If any column matches are found, the output of the cell will return the number of successfully added rows.

Append result

Keywords

write to sql, update data, writeback sql, DataFrame to database

Last modified: 06 September 2024