{ "cells": [ { "cell_type": "markdown", "id": "82d9ed3a-e587-4a3b-9de1-ac2a1f89feaf", "metadata": {}, "source": [ "# SQLAlchemy\n", "\n", "
\n", "\n", "[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/simphony/docs/v4.0.0?filepath=docs%2Fusage%2Fwrappers%2Fsqlalchemy.ipynb \"Click to run this tutorial yourself!\")\n", " \n", "
" ] }, { "cell_type": "markdown", "id": "dea73729-6ffb-4b06-9c4c-d24ed1a4310e", "metadata": {}, "source": [ "| **Capability** \t| **Support** \t|\n", "|:-----------:\t|:-----------:\t|\n", "| Persistence \t| ✓ \t|\n", "| Files \t| ✗ \t|\n", "| Simulation \t| ✗ \t|\n", "| Cache \t| ✗ \t|" ] }, { "cell_type": "markdown", "id": "326fdb5a-01e1-4c1b-adfe-cc369513bdef", "metadata": {}, "source": [ "The SQLAlchemy wrapper can store ontology individuals using several tables on any of the database backends suported by [SQLAlchemy](https://www.sqlalchemy.org/). It is based on the [rdflib-sqlalchemy](https://github.com/RDFLib/rdflib-sqlalchemy) package. The wrapper is included with SimPhoNy and available under `simphony_osp.wrappers.SQLAlchemy`." ] }, { "cell_type": "code", "execution_count": 1, "id": "1a77b8c1-1df7-4ea2-be35-99e895d9702f", "metadata": {}, "outputs": [], "source": [ "from simphony_osp.wrappers import SQLAlchemy" ] }, { "cell_type": "markdown", "id": "df69fe31-34e2-4d7b-ac42-d402bdeb0121", "metadata": {}, "source": [ "⠀" ] }, { "cell_type": "markdown", "id": "42f1a5ab-746f-46a0-b461-e5fd7670f4d5", "metadata": {}, "source": [ "**Configuration**" ] }, { "cell_type": "markdown", "id": "c62ac54c-ab0f-4335-ad7f-2f781bd9db8d", "metadata": {}, "source": [ "The [configuration string](introduction.ipynb) for the SQLAlchemy wrapper is an [SQLAlchemy Database URL](https://docs.sqlalchemy.org/en/14/core/engines.html#database-urls). To use the wrapper, just provide such an URL and the `create` argument." ] }, { "cell_type": "code", "execution_count": 2, "id": "ec2b9121-09e2-4804-9ec5-b7c3ac90d308", "metadata": {}, "outputs": [], "source": [ "sqlalchemy = SQLAlchemy('sqlite:///database.db', True)" ] }, { "cell_type": "markdown", "id": "3a88d725-3fd6-4ba0-ac15-6540b95a40ea", "metadata": {}, "source": [ "
\n", "
Tip
\n", " \n", "Check the [SQLAlchemy documentation](https://docs.sqlalchemy.org/en/14/core/engines.html#database-urls) to learn how to construct database URLs.\n", " \n", "
" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.8.12" } }, "nbformat": 4, "nbformat_minor": 5 }