comp.lang.ada
 help / color / mirror / Atom feed
From: ake.ragnar.dahlgren@gmail.com
Subject: Re: AWS Entry into the TechEmpower Framework Benchmark Project
Date: Thu, 21 Nov 2013 07:50:08 -0800 (PST)
Date: 2013-11-21T07:50:08-08:00	[thread overview]
Message-ID: <536649c2-ff71-4e01-b8a8-20871501afbc@googlegroups.com> (raw)
In-Reply-To: <f65c3d4a-080e-4e50-bb41-065b2cffb8f6@googlegroups.com>

On Tuesday, November 19, 2013 3:59:04 AM UTC+1, Shark8 wrote:
> TechEmpower is Benchmarking different frameworks for web-development ( http://www.techempower.com/benchmarks/#section=motivation&hw=i7&test=json ). There was no entry for AWS, or any other Ada showing (I know there's matreshka, and IIRC several Ada/CGI bindings), so I coded one up. Unfortunately there is no DB-functionality in it right now, as I couldn't get the ODBC to work, nor could I find a working InterBase (or FireBird) binding for Ada.

Using GNATCOLL it's possible to "talk" to a SQLite or PostgreSQL database. To use it you use a text file to describe the tables of your database (the schema). Then you use the executable gnatcoll_db2ada to generate the tables in the database (I've only used it for PostgreSQL), and then you use the same tool to generate the Ada code to be used by your application. Example usage:

To create the tables in the PostgreSQL database:
gnatcoll_db2ada -dbmodel=database_description.txt -dbhost=localhost -dbport=5432 -dbname=database_name -dbuser=user_name -dbpasswd=some_password -createdb

To generate the Ada files:
gnatcoll_db2ada -dbmodel=database_description.txt -api=Auto_Generated_Database_API

When using the SQL database in the Ada code you need the Connection instance.

         Description : GNATCOLL.SQL.Exec.Database_Description;
         Connection  : GNATCOLL.SQL.Exec.Database_Connection;

      Description := GNATCOLL.SQL.Postgres.Setup(Database      => Database_Name,
                                 User          => User_Name,
                                 Host          => Host_URL,
                                 Password      => User_Password,
                                 SSL           => Postgres.Allow,
                                 Cache_Support => True);
      Connection := GNATCOLL.SQL.GNATCOLL.SQL.Exec.Get_Task_Connection(Description  => Description);

When you are finished talking to the database (i.e. when it's time to shutdown the application) you need to:

      GNATCOLL.SQL.Exec.Free (Connection);
      GNATCOLL.SQL.Exec.Free (Description);

You can for example construct an SQL statements by:

      Query_Insert : constant GNATCOLL.SQL.SQL_Query :=
        GNATCOLL.SQL.SQL_Insert(Values => ...);

Before using it you always need to reset the connection to the database by:
      Connection.Reset_Connection;
Then you can execute the SQL statement using the connection instance:
      ... := Connection.Insert_And_Get_PK(Query => Query_Insert,
                                          PK => Auto_Generated_Database_API...);

For further details please read the GNATCOLL documentation.

Best regards,
Åke Ragnar Dahlgren

      parent reply	other threads:[~2013-11-21 15:50 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-19  2:59 AWS Entry into the TechEmpower Framework Benchmark Project Shark8
2013-11-19  2:59 ` Shark8
2013-11-28 12:32   ` Graham Stark
2013-11-21  7:21 ` Shark8
2013-11-21  8:08   ` Dmitry A. Kazakov
2013-11-21  8:46     ` Shark8
2013-11-21 12:46   ` Vadim Godunko
2013-11-21 17:38   ` Jeffrey Carter
2013-11-22  7:53     ` J Kimball
2013-11-21 19:32   ` Oliver Kleinke
2013-11-22  7:59     ` J Kimball
2013-11-22  7:38   ` Thomas Løcke
2013-11-22  8:37     ` Jacob Sparre Andersen
2013-11-22  9:14       ` Shark8
2013-11-22 10:16         ` ake.ragnar.dahlgren
2013-11-23  0:14           ` Shark8
2013-12-04  1:55             ` Shark8
2013-11-22 17:45       ` Ludovic Brenta
2013-11-23  9:41         ` Thomas Løcke
2013-11-21 15:50 ` ake.ragnar.dahlgren [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox