#!/usr/bin/env python # coding: utf-8 # In[1]: import duckdb # In[2]: duckdb.sql("select 42") # In[1]: get_ipython().run_line_magic('pip', 'install --quiet magic-duckdb') get_ipython().run_line_magic('load_ext', 'magic_duckdb') # In[2]: get_ipython().run_cell_magic('dql', '', 'SELECT 42;\n') # In[1]: get_ipython().run_line_magic('pip', 'install jupysql') get_ipython().run_line_magic('env', 'PLOOMBER_STATS_ENABLED="false"') get_ipython().run_line_magic('env', 'PLOOMBER_VERSION_CHECK_DISABLED="false"') get_ipython().run_line_magic('load_ext', 'sql') #https://jupysql.ploomber.io/en/latest/integrations/duckdb-native.html # In[4]: import pandas as pd import duckdb conn = duckdb.connect() df = pd.DataFrame({"x": range(10)}) # In[5]: get_ipython().run_line_magic('sql', 'conn') # In[6]: get_ipython().run_cell_magic('sql', '', 'SELECT *\nFROM df\nWHERE x > 4\n') # In[8]: df.to_csv("test.csv") # In[9]: get_ipython().run_cell_magic('sql', '', 'CREATE TABLE readcsvtest AS SELECT * FROM test.csv\n') # In[10]: get_ipython().run_cell_magic('sql', '', 'SELECT *\nFROM readcsvtest\nLIMIT 3\n') # In[ ]: