diff --git a/database-example/UseDatabase.ipynb b/database-example/UseDatabase.ipynb index 47830d3..5ee8f6d 100644 --- a/database-example/UseDatabase.ipynb +++ b/database-example/UseDatabase.ipynb @@ -309,6 +309,115 @@ "# You can also view individual tables\n", "db.connection.table(\"Publication\")" ] + }, + { + "cell_type": "code", + "execution_count": 19, + "id": "f8cad996-655f-46c3-b95e-2dc343e27717", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
✅ Inserted 1 rows into the database.\n",
+       "
\n" + ], + "text/plain": [ + "✅ Inserted \u001b[1;36m1\u001b[0m rows into the database.\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "
\n"
+      ],
+      "text/plain": []
+     },
+     "metadata": {},
+     "output_type": "display_data"
+    },
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "┏━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n",
+      "┃\u001b[1m \u001b[0m\u001b[1mname\u001b[0m\u001b[1m      \u001b[0m\u001b[1m \u001b[0m┃\u001b[1m \u001b[0m\u001b[1maffiliation\u001b[0m\u001b[1m \u001b[0m┃\u001b[1m \u001b[0m\u001b[1memail\u001b[0m\u001b[1m \u001b[0m\u001b[1m \u001b[0m┃\u001b[1m \u001b[0m\u001b[1morcid\u001b[0m\u001b[1m \u001b[0m\u001b[1m \u001b[0m┃\u001b[1m \u001b[0m\u001b[1mid\u001b[0m\u001b[1m                                  \u001b[0m\u001b[1m \u001b[0m┃\n",
+      "┡━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩\n",
+      "│ \u001b[2m!string\u001b[0m    │ \u001b[2mstring\u001b[0m      │ \u001b[2mstring\u001b[0m │ \u001b[2mstring\u001b[0m │ \u001b[2m!string\u001b[0m                              │\n",
+      "├────────────┼─────────────┼────────┼────────┼──────────────────────────────────────┤\n",
+      "│ \u001b[32mStrendaMan\u001b[0m │ \u001b[32mStrenda    \u001b[0m │ \u001b[2mNULL\u001b[0m   │ \u001b[2mNULL\u001b[0m   │ \u001b[32m00594dae-d6e0-4b6e-812f-0b994359f4af\u001b[0m │\n",
+      "│ \u001b[32mStrendaMan\u001b[0m │ \u001b[32mStrenda    \u001b[0m │ \u001b[2mNULL\u001b[0m   │ \u001b[2mNULL\u001b[0m   │ \u001b[32m1c60c513-a4e8-49c3-beb5-a07fa5022574\u001b[0m │\n",
+      "│ \u001b[32mStrendaMan\u001b[0m │ \u001b[32mStrenda    \u001b[0m │ \u001b[2mNULL\u001b[0m   │ \u001b[2mNULL\u001b[0m   │ \u001b[32m261012b1-446d-48da-8d70-8225256a497b\u001b[0m │\n",
+      "│ \u001b[32mStrendaMan\u001b[0m │ \u001b[32mStrenda    \u001b[0m │ \u001b[2mNULL\u001b[0m   │ \u001b[2mNULL\u001b[0m   │ \u001b[32m33cce500-64de-4e8a-b64d-3f78c30a8367\u001b[0m │\n",
+      "│ \u001b[32mStrendaMan\u001b[0m │ \u001b[32mStrenda    \u001b[0m │ \u001b[2mNULL\u001b[0m   │ \u001b[2mNULL\u001b[0m   │ \u001b[32m3e28623f-c5e7-4887-8025-bcd8f21afd29\u001b[0m │\n",
+      "│ \u001b[32mStrendaMan\u001b[0m │ \u001b[32mStrenda    \u001b[0m │ \u001b[2mNULL\u001b[0m   │ \u001b[2mNULL\u001b[0m   │ \u001b[32m4362f522-28ad-4a73-95a8-171f24f2c4b3\u001b[0m │\n",
+      "│ \u001b[32mStrendaMan\u001b[0m │ \u001b[32mStrenda    \u001b[0m │ \u001b[2mNULL\u001b[0m   │ \u001b[2mNULL\u001b[0m   │ \u001b[32m461f8c9d-8a75-4cd0-9f9c-2d8ab3414872\u001b[0m │\n",
+      "│ \u001b[32mJohn Doe  \u001b[0m │ \u001b[2mNULL\u001b[0m        │ \u001b[2mNULL\u001b[0m   │ \u001b[2mNULL\u001b[0m   │ \u001b[32m58c672ad-962e-45df-b820-e384003455b7\u001b[0m │\n",
+      "│ \u001b[32mStrendaMan\u001b[0m │ \u001b[32mStrenda    \u001b[0m │ \u001b[2mNULL\u001b[0m   │ \u001b[2mNULL\u001b[0m   │ \u001b[32m5b0931b8-cb72-4c7d-bc49-4d1fee79d551\u001b[0m │\n",
+      "│ \u001b[32mJohn Doe  \u001b[0m │ \u001b[2mNULL\u001b[0m        │ \u001b[2mNULL\u001b[0m   │ \u001b[2mNULL\u001b[0m   │ \u001b[32m5e407774-8196-4800-bb5f-ea9e1633c85e\u001b[0m │\n",
+      "│ \u001b[2m…\u001b[0m          │ \u001b[2m…\u001b[0m           │ \u001b[2m…\u001b[0m      │ \u001b[2m…\u001b[0m      │ \u001b[2m…\u001b[0m                                    │\n",
+      "└────────────┴─────────────┴────────┴────────┴──────────────────────────────────────┘\n"
+     ]
+    },
+    {
+     "data": {
+      "text/html": [
+       "
Looking for John Doe\n",
+       "
\n" + ], + "text/plain": [ + "Looking for John Doe\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "
┏━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n",
+       "┃ name      affiliation  email   orcid   id                                   ┃\n",
+       "┡━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩\n",
+       "│ !stringstringstringstring!string                              │\n",
+       "├──────────┼─────────────┼────────┼────────┼──────────────────────────────────────┤\n",
+       "│ John DoeNULLNULLNULL58c672ad-962e-45df-b820-e384003455b7 │\n",
+       "│ John DoeNULLNULLNULL5e407774-8196-4800-bb5f-ea9e1633c85e │\n",
+       "└──────────┴─────────────┴────────┴────────┴──────────────────────────────────────┘\n",
+       "
\n" + ], + "text/plain": [ + "┏━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n", + "┃\u001b[1m \u001b[0m\u001b[1mname\u001b[0m\u001b[1m \u001b[0m\u001b[1m \u001b[0m┃\u001b[1m \u001b[0m\u001b[1maffiliation\u001b[0m\u001b[1m \u001b[0m┃\u001b[1m \u001b[0m\u001b[1memail\u001b[0m\u001b[1m \u001b[0m\u001b[1m \u001b[0m┃\u001b[1m \u001b[0m\u001b[1morcid\u001b[0m\u001b[1m \u001b[0m\u001b[1m \u001b[0m┃\u001b[1m \u001b[0m\u001b[1mid\u001b[0m\u001b[1m \u001b[0m\u001b[1m \u001b[0m┃\n", + "┡━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩\n", + "│ \u001b[2m!string\u001b[0m │ \u001b[2mstring\u001b[0m │ \u001b[2mstring\u001b[0m │ \u001b[2mstring\u001b[0m │ \u001b[2m!string\u001b[0m │\n", + "├──────────┼─────────────┼────────┼────────┼──────────────────────────────────────┤\n", + "│ \u001b[32mJohn Doe\u001b[0m │ \u001b[2mNULL\u001b[0m │ \u001b[2mNULL\u001b[0m │ \u001b[2mNULL\u001b[0m │ \u001b[32m58c672ad-962e-45df-b820-e384003455b7\u001b[0m │\n", + "│ \u001b[32mJohn Doe\u001b[0m │ \u001b[2mNULL\u001b[0m │ \u001b[2mNULL\u001b[0m │ \u001b[2mNULL\u001b[0m │ \u001b[32m5e407774-8196-4800-bb5f-ea9e1633c85e\u001b[0m │\n", + "└──────────┴─────────────┴────────┴────────┴──────────────────────────────────────┘" + ] + }, + "execution_count": 19, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Suppose, we only want to add an author. You can proceed in the same way as above.\n", + "Author = db.get_table_api(\"Author\")\n", + "author1 = Author(name=\"John Doe\")\n", + "\n", + "# Add and lets check the table\n", + "db.insert(author1)\n", + "table = db.connection.table(\"Author\")\n", + "print(table)\n", + "\n", + "# We can also filter the table\n", + "rich.print(\"Looking for John Doe\")\n", + "table[table.name == \"John Doe\"]" + ] } ], "metadata": {