Skip to content

Commit 3187237

Browse files
committed
release
1 parent e67721f commit 3187237

File tree

2 files changed

+26
-33
lines changed

2 files changed

+26
-33
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Release notes
2+
3+
<!-- do not remove -->
4+
5+
## 0.0.1
6+
7+
- Initial release
8+

nbs/00_core.ipynb

Lines changed: 18 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@
396396
{
397397
"data": {
398398
"text/plain": [
399-
"<Database <sqlite3.Connection object at 0x12b38f790>>"
399+
"<Database <sqlite3.Connection object at 0x1373ab5b0>>"
400400
]
401401
},
402402
"execution_count": 18,
@@ -474,28 +474,22 @@
474474
},
475475
{
476476
"cell_type": "markdown",
477-
"metadata": {
478-
"heading_collapsed": true
479-
},
477+
"metadata": {},
480478
"source": [
481479
"## Database diagrams"
482480
]
483481
},
484482
{
485483
"cell_type": "markdown",
486-
"metadata": {
487-
"hidden": true
488-
},
484+
"metadata": {},
489485
"source": [
490486
"(Requires graphviz.)"
491487
]
492488
},
493489
{
494490
"cell_type": "code",
495491
"execution_count": 22,
496-
"metadata": {
497-
"hidden": true
498-
},
492+
"metadata": {},
499493
"outputs": [
500494
{
501495
"data": {
@@ -516,67 +510,58 @@
516510
{
517511
"cell_type": "code",
518512
"execution_count": 23,
519-
"metadata": {
520-
"hidden": true
521-
},
513+
"metadata": {},
522514
"outputs": [],
523515
"source": [
524516
"#| exports\n",
525517
"def _edge(tbl):\n",
526518
" return \"\\n\".join(f\"{fk.table}:{fk.column} -> {fk.other_table}:{fk.other_column};\"\n",
527519
" for fk in tbl.foreign_keys)\n",
528520
"\n",
529-
"def _edges(tbls): return \"\\n\".join(map(_edge, tbls))\n",
530-
"\n",
531521
"def _row(col):\n",
532522
" xtra = \" 🔑\" if col.is_pk else \"\"\n",
533523
" bg = ' bgcolor=\"#ffebcd\"' if col.is_pk else \"\"\n",
534524
" return f' <tr><td port=\"{col.name}\"{bg}>{col.name}{xtra}</td></tr>'\n",
535525
"\n",
536526
"def _tnode(tbl):\n",
537527
" rows = \"\\n\".join(_row(o) for o in tbl.columns)\n",
538-
" bg = ' bgcolor=\"lightgray\"'\n",
539528
" res = f\"\"\"<table cellborder=\"1\" cellspacing=\"0\">\n",
540-
" <tr><td{bg}>{tbl.name}</td></tr>\n",
529+
" <tr><td bgcolor=\"lightgray\">{tbl.name}</td></tr>\n",
541530
"{rows}\n",
542531
" </table>\"\"\"\n",
543-
" return f\"{tbl.name} [label=<{res}>];\\n\"\n",
544-
"\n",
545-
"def _tnodes(tbls): return \"\\n\\n\".join(_tnode(o) for o in tbls)"
532+
" return f\"{tbl.name} [label=<{res}>];\\n\""
546533
]
547534
},
548535
{
549536
"cell_type": "code",
550-
"execution_count": 24,
551-
"metadata": {
552-
"hidden": true
553-
},
537+
"execution_count": 26,
538+
"metadata": {},
554539
"outputs": [],
555540
"source": [
556541
"#| exports\n",
557542
"def diagram(tbls, ratio=0.7, size=\"10\", neato=False, render=True):\n",
558543
" layout = \"\\nlayout=neato;\\noverlap=prism;\\noverlap_scaling=0.5;\"\"\" if neato else \"\"\n",
559-
"\n",
544+
" edges = \"\\n\".join(map(_edge, tbls))\n",
545+
" tnodes = \"\\n\".join(map(_tnode, tbls))\n",
546+
" \n",
560547
" res = f\"\"\"digraph G {{\n",
561548
"rankdir=LR;{layout}\n",
562549
"size=\"{size}\";\n",
563550
"ratio={ratio};\n",
564551
"node [shape=plaintext]\n",
565552
"\n",
566-
"{_tnodes(tbls)}\n",
553+
"{tnodes}\n",
567554
"\n",
568-
"{_edges(tbls)}\n",
555+
"{edges}\n",
569556
"}}\n",
570557
"\"\"\"\n",
571558
" return Source(res) if render else res"
572559
]
573560
},
574561
{
575562
"cell_type": "code",
576-
"execution_count": 25,
577-
"metadata": {
578-
"hidden": true
579-
},
563+
"execution_count": 27,
564+
"metadata": {},
580565
"outputs": [
581566
{
582567
"data": {
@@ -890,10 +875,10 @@
890875
"</svg>\n"
891876
],
892877
"text/plain": [
893-
"<graphviz.sources.Source at 0x12b4c64d0>"
878+
"<graphviz.sources.Source at 0x137485950>"
894879
]
895880
},
896-
"execution_count": 25,
881+
"execution_count": 27,
897882
"metadata": {},
898883
"output_type": "execute_result"
899884
}

0 commit comments

Comments
 (0)