jupyter

Jupyter SQL Magic Persist

In Jupyter Lab, the %sql magic command persist creates a new table in the database to which we are connected. The table name will be the name as the name of the Python variable. Example: import pandas as pd df = pd.read_csv('/tmp/data.csv') df column1 column2 0 1 a 1 2 b 2 3 b # set environment variable $DATABASE_URL %sql postgresql://datacomy:PASSWORD@localhost/datacomy 'Connected: datacomy@datacomy' %sql persist df * postgresql://datacomy:***@localhost/datacomy 'Persisted df' %%sql SELECT tablename,tableowner FROM pg_catalog.