2022-12-17 06:41:32 +11:00
|
|
|
\chapter{Bases de données}
|
2023-10-09 06:56:41 +11:00
|
|
|
\label{chap:bdd} \index{SQL}
|
2022-12-17 06:41:32 +11:00
|
|
|
|
|
|
|
% ----------------------------------------------------------------
|
2023-10-09 06:56:41 +11:00
|
|
|
|
|
|
|
|
2022-12-17 06:41:32 +11:00
|
|
|
% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
\section{sqlite} \index{sqlite}
|
|
|
|
|
|
|
|
|
|
|
|
% ----------------------------------------------------------------
|
|
|
|
\subsection{CLI} \index{cli}
|
|
|
|
|
2023-11-30 00:12:03 +11:00
|
|
|
Commandes internes:
|
|
|
|
|
2022-12-17 06:41:32 +11:00
|
|
|
|
|
|
|
% ----------------------------------------------------------------
|
|
|
|
\subsection{Libreoffice} \index{Libreoffice}
|
|
|
|
|
2023-10-09 06:56:41 +11:00
|
|
|
|
|
|
|
|
2022-12-17 06:41:32 +11:00
|
|
|
% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
2023-10-09 06:56:41 +11:00
|
|
|
|
2022-12-17 06:41:32 +11:00
|
|
|
\section{GDBM} \index{GDBM}
|
|
|
|
|
2023-10-09 06:56:41 +11:00
|
|
|
\begin{quote}
|
|
|
|
GDBM - The GNU database manager. Includes dbm and ndbm compatibility.
|
|
|
|
\end{quote}
|
|
|
|
|
|
|
|
Gnu DBM permet de stocker des paires clef/valeur dans un fichier
|
|
|
|
de données. Chacune de ces clefs doit être unique, et doit être
|
|
|
|
liée avec une seule valeur\footnote{Peut-on alors parler
|
|
|
|
de bijection relationnelle ?}.
|
|
|
|
|
2022-12-17 06:41:32 +11:00
|
|
|
% ----------------------------------------------------------------
|
|
|
|
|
2023-10-09 06:56:41 +11:00
|
|
|
\subsection{Exemple en Perl} \index{Perl}
|
|
|
|
|
|
|
|
\begin{verbatim}
|
|
|
|
#!/usr/bin/perl -w
|
2022-12-17 06:41:32 +11:00
|
|
|
|
2023-10-09 06:56:41 +11:00
|
|
|
use strict;
|
|
|
|
use GDBM_File;
|
|
|
|
my $nomdb = "exemple.gdbm";
|
|
|
|
my (%DB, @champs);
|
|
|
|
my ($user, $gecos);
|
|
|
|
open(SOURCE, "< /etc/passwd") or die "source $!";
|
|
|
|
tie(%DB, "GDBM_File", $nomdb, GDBM_WRCREAT, 0666) or die "gdbm $!";
|
|
|
|
|
|
|
|
while (<SOURCE>) {
|
2023-11-30 00:12:03 +11:00
|
|
|
@champs = split ":", $_;
|
|
|
|
$user = $champs[0]."\0";
|
|
|
|
$gecos = $champs[4]."\0";
|
|
|
|
$DB{$user} = $gecos;
|
|
|
|
}
|
2023-10-09 06:56:41 +11:00
|
|
|
|
|
|
|
untie %DB;
|
|
|
|
close SOURCE;
|
|
|
|
0;
|
|
|
|
\end{verbatim}
|
2022-12-17 06:41:32 +11:00
|
|
|
|
2023-11-30 00:12:03 +11:00
|
|
|
Vous remarquerez que pour cet exemple, nous avons clef et valeur qui
|
|
|
|
sont du texte. Alors que DBM est prévu pour stocker des blocs de
|
|
|
|
binaire. Pour faciliter la récupération de ces chaines de caractères
|
|
|
|
par un hypothétique\footnote{Oui, je vais l'écrire bientôt.} programme
|
|
|
|
en C, le programme Perl rajoute un \texttt{'\textbackslash0'}
|
|
|
|
(fin de chaine) aux deux champs concernés.
|
|
|
|
|
2022-12-17 06:41:32 +11:00
|
|
|
% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
|
|
|
|
\section{Postgresql}
|
|
|
|
|
2023-10-09 06:56:41 +11:00
|
|
|
Le poids lourd du domaine.
|
|
|
|
|
|
|
|
% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
|
|
|
|
\section{Et le "NoSQL" ?} \index{nosql} \index{troll}
|
|
|
|
|
2022-12-17 06:41:32 +11:00
|
|
|
% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|