项目作者: stcarrez

项目描述 :
Ada数据库对象
高级语言: Ada
项目地址: git://github.com/stcarrez/ada-ado.git
创建时间: 2015-01-17T13:22:20Z
项目社区:https://github.com/stcarrez/ada-ado

开源协议:Apache License 2.0

下载


Ada Database Objects

Alire
Alire
Alire
Alire
Build Status
Test Status
Coverage
Documentation Status
Download
License
GitLab
Commits

Ada Database Objects is an Ada05 library that provides
object relational mapping to access a database in Ada05.
The library supports Postgresql, MySQL/MariaDB, SQLite as databases.
Most of the concepts developped for ADO come from the Java Hibernate ORM.

The ORM uses an YAML, XML mapping file or an UML model, a code generator and a runtime library
for the implementation. It provides a database driver for Postgresql,
MySQL/MariaDB and SQLite. The ORM helps your
application by providing a mapping of your database tables directly in the target programming
language: Ada05 in our case. The development process is the following:

  • You design your database model either using a UML tool or by writing a YAML or XML description,
  • You generate the Ada05 mapping files by using the Dynamo code generator,
  • You generate the SQL database tables by using the same tool,
  • You write your application on top of the generated code that gives you direct and simplified access to your database.

ADO Development model

You need at least one of these databases (or all of then). The configure script will now
fail if no supported database was found. Check the Database Drivers
section to install them and run the configure again after the installation.

Version 2.4.1 - Sep 2024

  • Cleanup build environment to drop configure

List all versions

Using with Alire

If you are using Alire in your project, run the following command
within your Alire project to use the library:

  1. alr with ado

Depending on your project, you may need one or some of the following other components
to get the support for SQLite, MySQL/MariaDB or PostgreSQL. Use ado_mysql for MariaDB.

  1. alr with ado_sqlite
  2. alr with ado_mysql
  3. alr with ado_postgresql

Using without Alire

If you don’t have Alire or want to build and install the library
on a specific place, run a setup command to configure the build as well as installation
directory.
For a detailed description on how you can configure, build and install the library
refer to the Installation guide.
Otherwise, you can easily configure and build the library with the steps described below.

The support for SQLite, MySQL/MariaDB and PostgreSQL are enabled only when a HAVE_XXX=yes configuration
variable is defined. Run the setup command that records in the Makefile.conf the configuration
you want to build.

The HAVE_ALIRE configuration allows you to build with Alire or not.

The example below enables the SQLite and PostgreSQL components but disables
the MySQL/MariaDB support and disables the use of Alire to build
the library.

  1. make setup BUILD=debug PREFIX=/build/install \
  2. HAVE_SQLITE=yes HAVE_POSTGRESQL=yes \
  3. HAVE_MYSQL=no HAVE_ALIRE=no

Then build, run the unit tests and install by using:

  1. make
  2. make test
  3. make install

To use the installed libraries, make sure your ADA_PROJECT_PATH contains the directory
where you installed the libraries (configured by the PREFIX=<path> option in the setup phase).
The installed GNAT projects are the same as those used when using Alire.

Samples

The samples can be built using:

  1. make samples

or

  1. cd samples
  2. alr build

Before launching the samples, the database must have been created.
For SQLite, use:

  1. make samples.db

Documentation

The Ada Database Objects sources as well as a wiki documentation is provided on:

Presentations

Database Drivers

The Postgresql, MySQL/MariaDB and SQLite development headers and runtime are necessary for building
the ADO driver. The configure script will use them to enable the ADO drivers.

Postgresql Development installation

  1. sudo apt-get install postgresql-client libpq-dev

MySQL/MariaDB Development installation

  1. sudo apt-get install mariadb-client libmariadb-dev

SQLite Development installation

  1. sudo apt-get install sqlite3 libsqlite3-dev

For Windows, check win32/README to install the libraries.

Database Creation

Create the tests database by using the Dynamo command.
(Dynamo is available at: https://gitlab.com/stcarrez/dynamo)
Note: change ‘root’ and ‘password’ to a MySQL/MariaDB user that has admin access rights
(‘create database’ and ‘grant option’ privileges).

  1. dynamo create-database db/regtests root password

The default database connection string is defined in dynamo.xml.
You can also specify the connection string and create the schema by using:

  1. dynamo create-database db/regtests 'mysql://localhost:3306/ado_test?user=ado' root password

MySQL/MariaDB setup

To create manually the database, you can proceed to the following steps:

  1. Create the ‘ado_test’ database in MySQL/MariaDB

    1. sudo mysql
    2. mysql> CREATE DATABASE ado_test;
  2. Create the ‘ado’ user and give the access rights:

    1. mysql> CREATE USER 'ado' IDENTIFIED BY '';
  1. mysql> GRANT SELECT, INSERT, UPDATE, DELETE,
  2. CREATE, DROP, CREATE TEMPORARY TABLES, EXECUTE,
  3. SHOW VIEW ON `ado_test`.* TO ado@'%';
  4. mysql> FLUSH PRIVILEGES;
  1. Create the tables
    1. mysql> USE ado_test
    2. mysql> SOURCE db/regtests/mysql/create-ado-mysql.sql

Postgresql setup

To create manually the database, you can proceed to the following steps:

  1. Create the ‘ado’ user and configure the password
    (enter ‘ado’ for the password or update the Makefile as well as the test-postgresql.properties file):

    1. sudo -u postgres createuser ado --pwprompt
  2. Create the ‘ado_test’ database in Postgresql

    1. sudo -u postgres createdb -O ado ado_test
  3. Create the tables

    1. psql "postgresql://localhost:5432/ado_test?user=ado&password=ado" \
    2. --file=db/regtests/postgresql/create-ado-postgresql.sql

Testing

Before running the unit tests for MySQL/MariaDB or Postgresql, you must create the
test database as described in Database Creation.

The unit tests are built and executed using:

  1. make test

To run manually the unit tests, use the following commands:

  1. bin/ado_harness -config test-mysql.properties

or

  1. bin/ado_harness -config test-sqlite.properties

or

  1. bin/ado_harness -config test-postgresql.properties

Building documentation

The ADO Programmer’s Guide is generated by using Dynamo
and Pandoc. You may need the following Debian packages:

  1. sudo apt-get install pandoc xsltproc texlive-latex-base texlive-latex-extra texlive-fonts-extra

The documentation is created by the following command:

  1. make doc

and the book is generated in the ado-book.pdf file.