Skip to content

Instantly share code, notes, and snippets.

@ninyawee
Created February 6, 2025 16:23
Show Gist options
  • Save ninyawee/94f8f13fb2d5e4db95e4b6911189d67f to your computer and use it in GitHub Desktop.
Save ninyawee/94f8f13fb2d5e4db95e4b6911189d67f to your computer and use it in GitHub Desktop.
jupyter sql init
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<span style=\"None\">The &#x27;toml&#x27; package isn&#x27;t installed. To load settings from pyproject.toml or ~/.jupysql/config, install with: pip install toml</span>"
],
"text/plain": [
"The 'toml' package isn't installed. To load settings from pyproject.toml or ~/.jupysql/config, install with: pip install toml"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"%load_ext dotenv\n",
"%dotenv .env.dev\n",
"import os\n",
"os.environ['DATABASE_URL'] = f\"postgresql://{os.getenv('PG_USER')}:{os.getenv('PG_PASSWORD')}@{os.getenv('PG_HOST')}:{os.getenv('PG_PORT')}/{os.getenv('PG_DBNAME')}\"\n",
"%load_ext sql\n",
"%sql "
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<span style=\"None\">Running query in &#x27;postgresql://postgres.kqvdraanznawlpxyrgdv:***@aws-0-ap-southeast-1.pooler.supabase.com:5432/postgres&#x27;</span>"
],
"text/plain": [
"Running query in 'postgresql://postgres.kqvdraanznawlpxyrgdv:***@aws-0-ap-southeast-1.pooler.supabase.com:5432/postgres'"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<span style=\"color: green\">1 rows affected.</span>"
],
"text/plain": [
"1 rows affected."
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<table>\n",
" <thead>\n",
" <tr>\n",
" <th>?column?</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <td>1</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>"
],
"text/plain": [
"+----------+\n",
"| ?column? |\n",
"+----------+\n",
"| 1 |\n",
"+----------+"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"%%sql\n",
"select 1"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": ".venv",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment