{
  "metadata": {
    "kernelspec": {
      "name": "python",
      "display_name": "Python (Pyodide)",
      "language": "python"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "python",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.8"
    }
  },
  "nbformat_minor": 4,
  "nbformat": 4,
  "cells": [
    {
      "cell_type": "code",
      "source": "import duckdb",
      "metadata": {
        "trusted": true
      },
      "outputs": [],
      "execution_count": 1
    },
    {
      "cell_type": "code",
      "source": "duckdb.sql(\"select 42\")",
      "metadata": {
        "trusted": true
      },
      "outputs": [
        {
          "execution_count": 2,
          "output_type": "execute_result",
          "data": {
            "text/plain": "┌───────┐\n│  42   │\n│ int32 │\n├───────┤\n│    42 │\n└───────┘"
          },
          "metadata": {}
        }
      ],
      "execution_count": 2
    },
    {
      "cell_type": "code",
      "source": "%pip install --quiet magic-duckdb\n%load_ext magic_duckdb",
      "metadata": {
        "trusted": true
      },
      "outputs": [],
      "execution_count": 1
    },
    {
      "cell_type": "code",
      "source": "%%dql\nSELECT 42;",
      "metadata": {
        "trusted": true
      },
      "outputs": [
        {
          "execution_count": 2,
          "output_type": "execute_result",
          "data": {
            "text/plain": "   42\n0  42",
            "text/html": "
\n\n
\n  \n    \n      | \n | 42\n | 
\n  \n  \n    \n      | 0\n | 42\n | 
\n  \n
\n
\n    \n        \n            | x\n | 
\n    \n    \n        \n            | 5\n | 
\n        \n            | 6\n | 
\n        \n            | 7\n | 
\n        \n            | 8\n | 
\n        \n            | 9\n | 
\n    \n
"
          },
          "metadata": {}
        }
      ],
      "execution_count": 6
    },
    {
      "cell_type": "code",
      "source": "df.to_csv(\"test.csv\")",
      "metadata": {
        "trusted": true
      },
      "outputs": [],
      "execution_count": 8
    },
    {
      "cell_type": "code",
      "source": "%%sql\nCREATE TABLE readcsvtest AS SELECT * FROM test.csv",
      "metadata": {
        "trusted": true
      },
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/plain": "Running query in 'DuckDBPyConnection'",
            "text/html": "Running query in 'DuckDBPyConnection'"
          },
          "metadata": {}
        },
        {
          "execution_count": 9,
          "output_type": "execute_result",
          "data": {
            "text/plain": "+-------+\n| Count |\n+-------+\n|   10  |\n+-------+",
            "text/html": "\n    \n        \n            | Count\n | 
\n    \n    \n        \n            | 10\n | 
\n    \n
"
          },
          "metadata": {}
        }
      ],
      "execution_count": 9
    },
    {
      "cell_type": "code",
      "source": "%%sql\nSELECT *\nFROM readcsvtest\nLIMIT 3",
      "metadata": {
        "trusted": true
      },
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/plain": "Running query in 'DuckDBPyConnection'",
            "text/html": "Running query in 'DuckDBPyConnection'"
          },
          "metadata": {}
        },
        {
          "execution_count": 10,
          "output_type": "execute_result",
          "data": {
            "text/plain": "+---------+---+\n| column0 | x |\n+---------+---+\n|    0    | 0 |\n|    1    | 1 |\n|    2    | 2 |\n+---------+---+",
            "text/html": "\n    \n        \n            | column0\n | x\n | 
\n    \n    \n        \n            | 0\n | 0\n | 
\n        \n            | 1\n | 1\n | 
\n        \n            | 2\n | 2\n | 
\n    \n
"
          },
          "metadata": {}
        }
      ],
      "execution_count": 10
    },
    {
      "cell_type": "code",
      "source": "    ",
      "metadata": {
        "trusted": true
      },
      "outputs": [],
      "execution_count": null
    }
  ]
}