DBL - Database Management Library é uma biblioteca em linguagem C++ que implementa um Gestor de Banco de dados relacional. A biblioteca DBL source code está sob termos da GNU General Public License.

Design

DBL é uma biblioteca que se torna parte integral do software aplicativo. Diferentemente de um SGBDR client–server que é um processo independente com o qual o aplicativo se comunica. O software aplicativo faz uso das funcionalidades da biblioteca DBL através de subrotina, que reduz a latência de acessos ao banco de dados pois chamadas à funções dentro de um mesmo processo são muito mais eficientes que em uma comunicação entre processos.

Programas de Exemplo Criando um banco de dados simples Este e um programa básico que cria um banco de dados simples. Entretanto, por ser uma tarefa que geralmente é realizada apenas uma vez, pode ser feita pelo DBL Command-Line Interface. #include "dbl.h"

int main() { path( "D:\\" ); //set the path to the folder where the files will be stored

database db("mydatabase"); //mydatabase is the name of the database db.new_tab("customer"); //create a new table called customer in the database

write(db); //write the database structure into a file

char pkey = 1; table *tab = db.get_tab("customer"); //get the table customer from the database tab->add_col("cod", INTEGER, 1, pkey); //add a column called cod to the table customer tab->add_col("name", CHARACTER, 32); //add a column called name to the table customer tab->add_col("brithdate", INTEGER, 3); tab->add_col("sex", CHARACTER, 1); tab->add_col("phone", INTEGER, 1); tab->set_structure(); write(*tab); //write the table structure into files create_data_file(*tab); //create the data file of the table customer

return 0; }

Inserindo um registro em uma tabela Este é um programa basico que insere um novo registro na tabela. #include "dbl.h"

int main() { path( "D:\\" ); //set the path to the folder where the files will be stored

database db("mydatabase"); //mydatabase is the name of the database read(db); //load the database structure

table *tab = db.get_tab("customer"); //get the table customer from the database row r( tab->new_row() ); //get a row with the structure of the table customer

int cod = 31415; char name = "Charles"; int birthdate = {27, 6, 2010}; char sex = 'm'; int phone = 88123456;

//set the values stored by the row r.set(0, &cod); r.set(1, name); r.set(2, birthdate); r.set(3, &sex); r.set(4, &phone);

int i = num_row(*tab); //get the number of rows in the data file

//write the row into the data file of the table customer, //where i is the index of the new record write(*tab, r, i );

return 0; }

DBL Command-Line Interface Pelo programa DBL Command-Line Interface pode-se criar banco de dados, criar tabelas e adicionar colunas à uma tabela, além de outras operações tais como mostrar na tela a estrutura dos banco de dados e tabelas.

Categoria:Bibliotecas de rotinas Categoria:Projeto GNU Categoria:Sistemas livres de gerenciamento de banco de dados Categoria:Software livre Categoria:Bibliotecas C++