Skip to content

Commit 6e85ea5

Browse files
committed
DB example
1 parent 83684c5 commit 6e85ea5

File tree

1 file changed

+51
-19
lines changed

1 file changed

+51
-19
lines changed

examples/db.ipynb

Lines changed: 51 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
},
1111
{
1212
"cell_type": "code",
13-
"execution_count": null,
13+
"execution_count": 1,
1414
"id": "06f33aaa",
1515
"metadata": {},
1616
"outputs": [],
@@ -29,10 +29,21 @@
2929
},
3030
{
3131
"cell_type": "code",
32-
"execution_count": null,
32+
"execution_count": 2,
3333
"id": "abc973d4",
3434
"metadata": {},
35-
"outputs": [],
35+
"outputs": [
36+
{
37+
"name": "stdout",
38+
"output_type": "stream",
39+
"text": [
40+
"Initializing DSClient...\n",
41+
"Authentication successful.\n",
42+
"DatabaseAccessor initialized. Connections will be created on first access.\n",
43+
"DSClient initialized.\n"
44+
]
45+
}
46+
],
3647
"source": [
3748
"# Authenticate & Initialize Client\n",
3849
"try:\n",
@@ -46,10 +57,29 @@
4657
},
4758
{
4859
"cell_type": "code",
49-
"execution_count": null,
60+
"execution_count": 3,
5061
"id": "3c1d34e8",
5162
"metadata": {},
52-
"outputs": [],
63+
"outputs": [
64+
{
65+
"name": "stdout",
66+
"output_type": "stream",
67+
"text": [
68+
"\n",
69+
"Creating database convenience variables...\n",
70+
"First access to 'ngl', initializing DSDatabase...\n",
71+
"Creating SQLAlchemy engine for database 'sjbrande_ngl_db' (ngl)...\n",
72+
"Engine for 'ngl' created.\n",
73+
"First access to 'vp', initializing DSDatabase...\n",
74+
"Creating SQLAlchemy engine for database 'sjbrande_vpdb' (vp)...\n",
75+
"Engine for 'vp' created.\n",
76+
"First access to 'eq', initializing DSDatabase...\n",
77+
"Creating SQLAlchemy engine for database 'post_earthquake_recovery' (eq)...\n",
78+
"Engine for 'eq' created.\n",
79+
"Database variables (ngl, vp, eq) created.\n"
80+
]
81+
}
82+
],
5383
"source": [
5484
"# Create Convenience Variables for Databases (Optional but meets user request)\n",
5585
"print(\"\\nCreating database convenience variables...\")\n",
@@ -87,25 +117,27 @@
87117
" except Exception as e:\n",
88118
" print(f\"\\nAn error occurred during NGL database query: {e}\")\n",
89119
"else:\n",
90-
" print(\"\\nSkipping NGL query as 'ngl' variable is not available.\")\n",
91-
"\n",
92-
"if vp: # Check if vp variable was successfully created\n",
93-
" try:\n",
94-
" print(\"\\nQuerying VP Database using 'vp' variable (as dict)...\")\n",
95-
" sql_vp = \"SELECT vp_id, vp_name FROM viewports LIMIT 3\"\n",
96-
" dict_vp = vp.read_sql(sql_vp, output_type=\"dict\")\n",
97-
" print(\"--- VP Data (List of Dicts) ---\")\n",
98-
" print(json.dumps(dict_vp, indent=2))\n",
99-
" except Exception as e:\n",
100-
" print(f\"\\nAn error occurred during VP database query: {e}\")\n",
101-
"else:\n",
102-
" print(\"\\nSkipping VP query as 'vp' variable is not available.\")"
120+
" print(\"\\nSkipping NGL query as 'ngl' variable is not available.\")"
103121
]
104122
}
105123
],
106124
"metadata": {
125+
"kernelspec": {
126+
"display_name": "dapi-ptztLUqK-py3.13",
127+
"language": "python",
128+
"name": "python3"
129+
},
107130
"language_info": {
108-
"name": "python"
131+
"codemirror_mode": {
132+
"name": "ipython",
133+
"version": 3
134+
},
135+
"file_extension": ".py",
136+
"mimetype": "text/x-python",
137+
"name": "python",
138+
"nbconvert_exporter": "python",
139+
"pygments_lexer": "ipython3",
140+
"version": "3.13.3"
109141
}
110142
},
111143
"nbformat": 4,

0 commit comments

Comments
 (0)