From cdfaf273631b4cc421a7cf5079188052fe9893e9 Mon Sep 17 00:00:00 2001
From: Emmanuel Bruno <emmanuel.bruno@univ-tln.fr>
Date: Fri, 12 Nov 2021 16:02:26 +0100
Subject: [PATCH] fixes mocodo example.

---
 .gitignore        |   1 +
 SQL sandbox.ipynb | 195 +++++++++++++++++++++++++++++++++-------------
 2 files changed, 144 insertions(+), 52 deletions(-)

diff --git a/.gitignore b/.gitignore
index e0195e8..0a7c117 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
 mocodo_notebook
 .ipynb_checkpoints
+work
diff --git a/SQL sandbox.ipynb b/SQL sandbox.ipynb
index c6bddeb..51761a3 100644
--- a/SQL sandbox.ipynb	
+++ b/SQL sandbox.ipynb	
@@ -42,7 +42,7 @@
       "image/svg+xml": [
        "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:link=\"http://www.w3.org/1999/xlink\" width=\"364\" height=\"200\" view_box=\"0 0 364 200\">\n",
        "\n",
-       "<desc>Generated by Mocodo 2.3.9 on Mon, 08 Nov 2021 14:27:51</desc>\n",
+       "<desc>Generated by Mocodo 2.3.9 on Fri, 12 Nov 2021 14:48:48</desc>\n",
        "\n",
        "<rect id=\"frame\" x=\"0\" y=\"0\" width=\"364\" height=\"200\" fill=\"none\" stroke=\"none\" stroke-width=\"0\"/>\n",
        "\n",
@@ -179,7 +179,7 @@
     }
    ],
    "source": [
-    "%%mocodo --title=client_commande --mld --relations=postgresql\n",
+    "%%mocodo --title=client_commande --mld --relations diagram markdown_data_dict\n",
     "PRODUIT: code, prix_unitaire\n",
     "INCLURE, 1N COMMANDE, 0N PRODUIT: Quantité    \n",
     "COMMANDE: numero, date\n",
@@ -188,6 +188,109 @@
     "PASSER, 0N CLIENT, 11 COMMANDE    "
    ]
   },
+  {
+   "cell_type": "code",
+   "execution_count": 3,
+   "id": "2e4b123b-29e2-456b-a7df-8b484397163b",
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "image/svg+xml": [
+       "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:link=\"http://www.w3.org/1999/xlink\" width=\"492\" height=\"209\" view_box=\"0 0 492 209\">\n",
+       "\n",
+       "<desc>Generated by Mocodo 2.3.9 on Fri, 12 Nov 2021 14:48:48</desc>\n",
+       "\n",
+       "<rect id=\"frame\" x=\"0\" y=\"0\" width=\"492\" height=\"209\" fill=\"none\" stroke=\"none\" stroke-width=\"0\"/>\n",
+       "\n",
+       "<!-- Entity PRODUIT -->\n",
+       "<g id=\"entity-PRODUIT\">\n",
+       "\t<g id=\"frame-PRODUIT\">\n",
+       "\t\t<rect x=\"42\" y=\"18\" width=\"120\" height=\"26\" fill=\"#FFFFFF\" stroke=\"#FFFFFF\" stroke-width=\"0\"/>\n",
+       "\t\t<rect x=\"42\" y=\"44.0\" width=\"120\" height=\"44\" fill=\"#FFFFFF\" stroke=\"#FFFFFF\" stroke-width=\"0\"/>\n",
+       "\t\t<rect x=\"42\" y=\"18\" width=\"120\" height=\"70\" fill=\"none\" stroke=\"#000000\" stroke-width=\"1.5\"/>\n",
+       "\t\t<line x1=\"42\" y1=\"44\" x2=\"162\" y2=\"44\" stroke=\"#000000\" stroke-width=\"1\"/>\n",
+       "\t</g>\n",
+       "\t<text x=\"72\" y=\"36.6\" fill=\"#000000\" font-family=\"Courier New\" font-size=\"14\">PRODUIT</text>\n",
+       "\t<text x=\"47\" y=\"62.6\" fill=\"#000000\" font-family=\"Courier New\" font-size=\"14\">code</text>\n",
+       "\t<line x1=\"47\" y1=\"65.0\" x2=\"82\" y2=\"65.0\" stroke=\"#000000\" stroke-width=\"1\"/>\n",
+       "\t<text x=\"47\" y=\"80.6\" fill=\"#000000\" font-family=\"Courier New\" font-size=\"14\">prix_unitaire</text>\n",
+       "</g>\n",
+       "\n",
+       "<!-- Entity INCLURE -->\n",
+       "<g id=\"entity-INCLURE\">\n",
+       "\t<g id=\"frame-INCLURE\">\n",
+       "\t\t<rect x=\"228\" y=\"9\" width=\"78\" height=\"26\" fill=\"#FFFFFF\" stroke=\"#FFFFFF\" stroke-width=\"0\"/>\n",
+       "\t\t<rect x=\"228\" y=\"35.0\" width=\"78\" height=\"62\" fill=\"#FFFFFF\" stroke=\"#FFFFFF\" stroke-width=\"0\"/>\n",
+       "\t\t<rect x=\"228\" y=\"9\" width=\"78\" height=\"88\" fill=\"none\" stroke=\"#000000\" stroke-width=\"1.5\"/>\n",
+       "\t\t<line x1=\"228\" y1=\"35\" x2=\"306\" y2=\"35\" stroke=\"#000000\" stroke-width=\"1\"/>\n",
+       "\t</g>\n",
+       "\t<text x=\"237\" y=\"27.6\" fill=\"#000000\" font-family=\"Courier New\" font-size=\"14\">INCLURE</text>\n",
+       "\t<text x=\"233\" y=\"53.6\" fill=\"#000000\" font-family=\"Courier New\" font-size=\"14\">#numero</text>\n",
+       "\t<line x1=\"233\" y1=\"56.0\" x2=\"293\" y2=\"56.0\" stroke=\"#000000\" stroke-width=\"1\"/>\n",
+       "\t<text x=\"233\" y=\"71.6\" fill=\"#000000\" font-family=\"Courier New\" font-size=\"14\">#code</text>\n",
+       "\t<line x1=\"233\" y1=\"74.0\" x2=\"276\" y2=\"74.0\" stroke=\"#000000\" stroke-width=\"1\"/>\n",
+       "\t<text x=\"233\" y=\"89.6\" fill=\"#000000\" font-family=\"Courier New\" font-size=\"14\">Quantité</text>\n",
+       "</g>\n",
+       "\n",
+       "<!-- Entity COMMANDE -->\n",
+       "<g id=\"entity-COMMANDE\">\n",
+       "\t<g id=\"frame-COMMANDE\">\n",
+       "\t\t<rect x=\"372\" y=\"9\" width=\"78\" height=\"26\" fill=\"#FFFFFF\" stroke=\"#FFFFFF\" stroke-width=\"0\"/>\n",
+       "\t\t<rect x=\"372\" y=\"35.0\" width=\"78\" height=\"62\" fill=\"#FFFFFF\" stroke=\"#FFFFFF\" stroke-width=\"0\"/>\n",
+       "\t\t<rect x=\"372\" y=\"9\" width=\"78\" height=\"88\" fill=\"none\" stroke=\"#000000\" stroke-width=\"1.5\"/>\n",
+       "\t\t<line x1=\"372\" y1=\"35\" x2=\"450\" y2=\"35\" stroke=\"#000000\" stroke-width=\"1\"/>\n",
+       "\t</g>\n",
+       "\t<text x=\"377\" y=\"27.6\" fill=\"#000000\" font-family=\"Courier New\" font-size=\"14\">COMMANDE</text>\n",
+       "\t<text x=\"377\" y=\"53.6\" fill=\"#000000\" font-family=\"Courier New\" font-size=\"14\">numero</text>\n",
+       "\t<line x1=\"377\" y1=\"56.0\" x2=\"429\" y2=\"56.0\" stroke=\"#000000\" stroke-width=\"1\"/>\n",
+       "\t<text x=\"377\" y=\"71.6\" fill=\"#000000\" font-family=\"Courier New\" font-size=\"14\">date</text>\n",
+       "\t<text x=\"377\" y=\"89.6\" fill=\"#000000\" font-family=\"Courier New\" font-size=\"14\">#email</text>\n",
+       "</g>\n",
+       "\n",
+       "<!-- Entity CLIENT -->\n",
+       "<g id=\"entity-CLIENT\">\n",
+       "\t<g id=\"frame-CLIENT\">\n",
+       "\t\t<rect x=\"71\" y=\"112\" width=\"62\" height=\"26\" fill=\"#FFFFFF\" stroke=\"#FFFFFF\" stroke-width=\"0\"/>\n",
+       "\t\t<rect x=\"71\" y=\"138.0\" width=\"62\" height=\"62\" fill=\"#FFFFFF\" stroke=\"#FFFFFF\" stroke-width=\"0\"/>\n",
+       "\t\t<rect x=\"71\" y=\"112\" width=\"62\" height=\"88\" fill=\"none\" stroke=\"#000000\" stroke-width=\"1.5\"/>\n",
+       "\t\t<line x1=\"71\" y1=\"138\" x2=\"133\" y2=\"138\" stroke=\"#000000\" stroke-width=\"1\"/>\n",
+       "\t</g>\n",
+       "\t<text x=\"76\" y=\"130.6\" fill=\"#000000\" font-family=\"Courier New\" font-size=\"14\">CLIENT</text>\n",
+       "\t<text x=\"76\" y=\"156.6\" fill=\"#000000\" font-family=\"Courier New\" font-size=\"14\">email</text>\n",
+       "\t<line x1=\"76\" y1=\"159.0\" x2=\"119\" y2=\"159.0\" stroke=\"#000000\" stroke-width=\"1\"/>\n",
+       "\t<text x=\"76\" y=\"174.6\" fill=\"#000000\" font-family=\"Courier New\" font-size=\"14\">nom</text>\n",
+       "\t<text x=\"76\" y=\"192.6\" fill=\"#000000\" font-family=\"Courier New\" font-size=\"14\">prenom</text>\n",
+       "</g>\n",
+       "\n",
+       "<!-- Link from \"numero\" (INCLURE) to \"numero\" (COMMANDE) -->\n",
+       "<path d=\"M306 49.0 C 339.0 49.0 328.0 49.0 372 49.0\" fill=\"none\" stroke=\"#000000\" stroke-width=\"1\"/>\n",
+       "<path d=\"M 372 49.0 L 360.0 55.0 L 364.0 49.0 L 360.0 43.0 Z\" fill=\"#000000\" stroke-width=\"0\"/>\n",
+       "<circle cx=\"306\" cy=\"49.0\" r=\"1.5\" stroke=\"#000000\" stroke-width=\"1.5\" fill=\"#000000\"/>\n",
+       "\n",
+       "<!-- Link from \"code\" (INCLURE) to \"code\" (PRODUIT) -->\n",
+       "<path d=\"M228 67.0 C 195.0 62.5 206.0 58.0 162 58.0\" fill=\"none\" stroke=\"#000000\" stroke-width=\"1\"/>\n",
+       "<path d=\"M 162 58.0 L 174.0 52.0 L 170.0 58.0 L 174.0 64.0 Z\" fill=\"#000000\" stroke-width=\"0\"/>\n",
+       "<circle cx=\"228\" cy=\"67.0\" r=\"1.5\" stroke=\"#000000\" stroke-width=\"1.5\" fill=\"#000000\"/>\n",
+       "\n",
+       "<!-- Link from \"email\" (COMMANDE) to \"email\" (CLIENT) -->\n",
+       "<path d=\"M372 85.0 C 252.5 118.5 292.3333333333333 152.0 133 152.0\" fill=\"none\" stroke=\"#000000\" stroke-width=\"1\"/>\n",
+       "<path d=\"M 133 152.0 L 145.0 146.0 L 141.0 152.0 L 145.0 158.0 Z\" fill=\"#000000\" stroke-width=\"0\"/>\n",
+       "<circle cx=\"372\" cy=\"85.0\" r=\"1.5\" stroke=\"#000000\" stroke-width=\"1.5\" fill=\"#000000\"/>\n",
+       "</svg>"
+      ],
+      "text/plain": [
+       "<IPython.core.display.SVG object>"
+      ]
+     },
+     "metadata": {},
+     "output_type": "display_data"
+    }
+   ],
+   "source": [
+    "mocodo --input mocodo_notebook/sandbox.mld"
+   ]
+  },
   {
    "cell_type": "markdown",
    "id": "685c0300-3bf6-4633-840d-6b068f2619ac",
@@ -207,7 +310,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 3,
+   "execution_count": 18,
    "id": "d9f7e6ac-7e6e-4870-8bdd-3f9620d6899d",
    "metadata": {},
    "outputs": [],
@@ -217,7 +320,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 4,
+   "execution_count": 23,
    "id": "82f26e33-c402-4a03-9d17-3878868b4a12",
    "metadata": {
     "tags": []
@@ -272,7 +375,7 @@
        "<IPython.core.display.SVG object>"
       ]
      },
-     "execution_count": 4,
+     "execution_count": 23,
      "metadata": {},
      "output_type": "execute_result"
     }
@@ -318,7 +421,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 5,
+   "execution_count": 24,
    "id": "ca072ea3-2f43-4542-a7ba-2d4921ca152f",
    "metadata": {
     "tags": []
@@ -340,7 +443,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 14,
+   "execution_count": 25,
    "id": "cfbca6ff-1393-43da-aa4c-16869fa6f8e0",
    "metadata": {},
    "outputs": [],
@@ -359,7 +462,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 15,
+   "execution_count": 26,
    "id": "2c918a0c-5a0f-4db0-b76a-6ae37d13589a",
    "metadata": {},
    "outputs": [
@@ -368,25 +471,13 @@
      "output_type": "stream",
      "text": [
       " * postgresql://localhost/jovyandb\n",
-      "Done.\n",
-      "Done.\n",
-      "Done.\n",
-      "Done.\n",
-      "Done.\n",
-      "Done.\n",
-      "Done.\n",
-      "Done.\n"
+      "(psycopg2.OperationalError) server closed the connection unexpectedly\n",
+      "\tThis probably means the server terminated abnormally\n",
+      "\tbefore or while processing the request.\n",
+      "\n",
+      "[SQL: DROP TABLE IF EXISTS LIGNE_DE_COMMANDE;]\n",
+      "(Background on this error at: https://sqlalche.me/e/14/e3q8)\n"
      ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[]"
-      ]
-     },
-     "execution_count": 15,
-     "metadata": {},
-     "output_type": "execute_result"
     }
    ],
    "source": [
@@ -431,7 +522,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 16,
+   "execution_count": 27,
    "id": "e3b35f69-a5eb-4888-b518-84f3a0841fba",
    "metadata": {},
    "outputs": [
@@ -440,20 +531,12 @@
      "output_type": "stream",
      "text": [
       " * postgresql://localhost/jovyandb\n",
-      "1 rows affected.\n",
-      "1 rows affected.\n",
-      "1 rows affected.\n"
+      "(psycopg2.OperationalError) FATAL:  database \"jovyandb\" does not exist\n",
+      "\n",
+      "[SQL: INSERT INTO CLIENT (email, nom, prenom) VALUES ('a.b@x.fr','a','b');]\n",
+      "[parameters: [{'__name__': '__main__', '__doc__': 'Automatically created module for IPython interactive environment', '__package__': None, '__loader__': None, '__s ... (24748 characters truncated) ... ','b');\\nINSERT INTO CLIENT (email, nom, prenom) VALUES ('c.d@x.fr','c','d');\\nINSERT INTO CLIENT (email, nom, prenom) VALUES ('e.f@x.fr','e','f');\"}]]\n",
+      "(Background on this error at: https://sqlalche.me/e/14/e3q8)\n"
      ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[]"
-      ]
-     },
-     "execution_count": 16,
-     "metadata": {},
-     "output_type": "execute_result"
     }
    ],
    "source": [
@@ -465,7 +548,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 17,
+   "execution_count": 9,
    "id": "9232e8ad-c21e-4bf1-b92d-30be7ec5d94a",
    "metadata": {},
    "outputs": [
@@ -513,7 +596,7 @@
        " (3, 'e.f@x.fr', 'e', 'f')]"
       ]
      },
-     "execution_count": 17,
+     "execution_count": 9,
      "metadata": {},
      "output_type": "execute_result"
     }
@@ -533,7 +616,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 18,
+   "execution_count": 10,
    "id": "c0e8873f-6c46-455d-829d-d042770d9e08",
    "metadata": {},
    "outputs": [
@@ -564,7 +647,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 19,
+   "execution_count": 11,
    "id": "cc525ac0-15e4-4ef8-a16b-cad00ce948e3",
    "metadata": {},
    "outputs": [
@@ -584,7 +667,7 @@
        "[]"
       ]
      },
-     "execution_count": 19,
+     "execution_count": 11,
      "metadata": {},
      "output_type": "execute_result"
     }
@@ -598,7 +681,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 20,
+   "execution_count": 12,
    "id": "2ba87c2d-65bf-45f9-a71c-1130c11c7e2b",
    "metadata": {},
    "outputs": [
@@ -640,7 +723,7 @@
        "[(1, 'pomme', 2), (2, 'peche', 4), (3, 'poire', 3)]"
       ]
      },
-     "execution_count": 20,
+     "execution_count": 12,
      "metadata": {},
      "output_type": "execute_result"
     }
@@ -652,7 +735,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 21,
+   "execution_count": 13,
    "id": "e68b5145-ea69-4574-ac1c-6f1c67de5567",
    "metadata": {},
    "outputs": [
@@ -680,7 +763,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 22,
+   "execution_count": 14,
    "id": "ea570c9b-8b52-4099-b5ac-fd14e880def0",
    "metadata": {},
    "outputs": [
@@ -725,7 +808,7 @@
        "[(1, 1, 5), (1, 2, 2), (1, 3, 1)]"
       ]
      },
-     "execution_count": 22,
+     "execution_count": 14,
      "metadata": {},
      "output_type": "execute_result"
     }
@@ -749,7 +832,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 23,
+   "execution_count": 15,
    "id": "96f25786-c320-49ff-8345-88edd2f827ec",
    "metadata": {},
    "outputs": [
@@ -767,7 +850,7 @@
        "<AxesSubplot:xlabel='description'>"
       ]
      },
-     "execution_count": 23,
+     "execution_count": 15,
      "metadata": {},
      "output_type": "execute_result"
     },
@@ -797,6 +880,14 @@
    "metadata": {},
    "outputs": [],
    "source": []
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "id": "d16e8357-90f9-4b4f-8b51-08117112cdda",
+   "metadata": {},
+   "outputs": [],
+   "source": []
   }
  ],
  "metadata": {
-- 
GitLab