{ "cells": [ { "cell_type": "code", "execution_count": null, "id": "18414ef7-739d-47b9-b3ef-ffe8ff29cfa8", "metadata": {}, "outputs": [], "source": [ "# Importing libraries\n", "import sqlite3\n", "import pandas" ] }, { "cell_type": "markdown", "id": "39742f38-5f10-4088-8423-27798c3235ac", "metadata": {}, "source": [ "D'abord on établit une connexion à la base de données :" ] }, { "cell_type": "code", "execution_count": null, "id": "40eb692d-b7f0-4c1f-96f5-8e99e54d2921", "metadata": {}, "outputs": [], "source": [ "# Etablir la connexion à la base de données\n", "con = sqlite3.connect(\"india.sqlite\")" ] }, { "cell_type": "code", "execution_count": null, "id": "7a8829ae-6f4a-45a7-b8d5-3f84751cbca0", "metadata": {}, "outputs": [], "source": [ "# Charger l'extension spatialite\n", "con.enable_load_extension(True)\n", "con.load_extension(\"mod_spatialite\")" ] }, { "cell_type": "code", "execution_count": null, "id": "2799208d-39ee-48af-bc2c-c3ceca3c3f06", "metadata": {}, "outputs": [], "source": [ "# Donner la requête à executer\n", "query = \"select AsText(geometry) as geometry_wkt from Village\"\n", "\n", "# Executer la requête et récupérer la table résultat\n", "resulttable = pandas.read_sql_query(query, con)\n", "\n", "# Afficher la table résultat\n", "display(resulttable)" ] }, { "cell_type": "code", "execution_count": null, "id": "0450c8de-85d0-4e19-96e9-7bd942e8b410", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "py_spatial", "language": "python", "name": "py_spatial" }, "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.10" } }, "nbformat": 4, "nbformat_minor": 5 }