Login Register Actian.com  

Actian Community Wiki

Navigation
Learn About
Developing With
Ingres Talk
Information
Toolbox

Ruby/Learn/Flight Planner Demo Application

From Ingres Community Wiki

Jump to: navigation, search

Contents

Introduction

The initial implementation of the Frequent Flyer Demo was written in C#. The demonstration application is a standalone Windows desktop program that uses System.Windows.* API calls that come with Windows OS for its GUI components and makes direct SQL queries to Ingres .NET DataProvider. It doesn't require any external libraries. This application is provided under the demo directory of an Ingres installation if the .NET Data Provider and the demodb is installed. The source code for the Csharp version can be found in the Ingres SVN repository at

 http://code.ingres.com/ingres/main/src/front/demo/csharp/ 

and as part of a installation of Ingres on Windows in:

 %II_SYSTEM%\ingres\demo\csharp\travel 

Since the initial implementation of the C# demo a similar application has been been ported to two additional languages:

Like the C# The Ingres Ruby Frequent Flyer demo is a stand alone application that uses the TK GUI controls via RubyTK bindings to provide the visual interface with the Ingres Ruby driver used to connect to the demodb database.

Features

The demonstration application consists of 3 functional areas each utilizing different parts of the Ingres Ruby driver and DBMS server:

Routes Lets you find a route between airports, demonstrating the following:

  • SELECT queries that require parameters
  • Execution of a row producing procedure
  • INSERT, UPDATE, and DELETE queries

Profile Lets you select or create details for a "Frequent Flyer," demonstrating the following:

  • Use of Unicode character types
  • Handling of binary large objects (BLOBs)

Connect

  • Lets you set up connection details to an Ingres instance.

The documentation for each method used to access Ingres can be found at http://code.ingres.com/ingres/main/src/front/demo/ruby/IngresDemoApp_ruby/doc/index.html.

Requirements

The Frequent Flyer demo has been written to run on the same platforms on which Ruby is available. The only external dependency is the binding for Ruby-Tk - one of a number of GUI interfaces available for Ruby applications.

Linux

At the present time the demo has only been tested using Fedora Linux, with the dependencies listed below. Should you wish to run the application on another distribution it should be possible providing the equivalent packages are installed.

Fedora

The following system packages are required:

  • ruby
  • ruby-tcltk
  • ruby-devel
  • gcc

Install them using the following command:

sudo yum install ruby ruby-tcltk ruby-devel gcc

Windows

Running the Frequent Flyer demo on Windows requires the following software be installed. Note that the demo app has not been tested with Ruby 1.9, since the Ruby driver for Ingres has not been built for that platform.

require 'tk'

Ingres Permissions

The permissions on the underlying database tables and procedures, used by the demonstration application, assume you are logged in as ingres or the same user Ingres was installed as. If this is not the case you will need to execute the following SQL statements:

grant all on airline,airport,country,flight_day,full_route,route,user_profile,version to public;
grant execute on procedure get_my_airports, get_airports, get_my_airlines,get_airlines, search_route to public;

Under Fedora Linux you can issue the following command, as ingres

sql demodb <<EOSQL
grant all on airline,airport,country,flight_day,full_route,route,user_profile,version to public;
grant execute on procedure get_my_airports, get_airports, get_my_airlines,get_airlines, search_route to public;
grant next on sequence up_id to public;
\p\g
EOSQL

generating the following output:

$ sql demodb <<EOSQL
> grant all on airline,airport,country,flight_day,full_route,route,user_profile,version to public;
> grant execute on procedure get_my_airports, get_airports, get_my_airlines,get_airlines, search_route to public;
> grant next on sequence up_id to public;
> \p\g
> EOSQL
INGRES TERMINAL MONITOR Copyright 2010 Ingres Corporation
Ingres Linux Version II 10.0.0 (int.lnx/132)NPTL login
Fri Nov 12 10:09:18 2010
Enter \g to execute commands, "help help\g" for help, \q to quit

continue
* * * * /* SQL Startup File */
grant all on airline,airport,country,flight_day,full_route,route,user_profile,version to public;
grant execute on procedure get_my_airports, get_airports, get_my_airlines,get_airlines, search_route to public;
grant next on sequence up_id to public;
Executing . . .

continue
* 
Your SQL statement(s) have been committed.

Ingres Version II 10.0.0 (int.lnx/132)NPTL logout
Fri Nov 12 10:09:18 2010

Ingres Ruby Driver

In order run the flight planner demo application you need to install version 1.4.1 (or newer) of the Ruby driver. The latest release can be obtained from http://esd.ingres.com via one of the following links:

Installing

To install the driver from the source code archive you first need to build the driver. With the archive extracted execute the following commands, making sure you have a valid Ingres environment:

cd ruby-ingres-1.4.1/ext
ruby extconf.rb
make
sudo make install

If you have downloaded the Windows pre-built binary, place the Ingres.so library in C:\ruby\lib\ruby\site_ruby\1.8\i386-msvcrt.

Verify you can load the driver using irb:

irb
require 'Ingres'

This should give you the following output

$ irb
irb(main):001:0> require 'Ingres'
=> true
irb(main):002:0> 

If not, make sure you have your Ingres environment setup correctly and that Ingres.so is in the correct location.

Obtaining the demo code

The code and supporting documentation are available for download in ZIP and Gzip archive from http://esd.ingres.com/product/Community_Projects/Drivers/Source_Code/Ruby_Frequent_Flyer_Demo/. Or from SVN via checkout:

svn co http://code.ingres.com/ingres/main/src/front/demo/ruby/IngresDemoApp_ruby/

Once extracted you should have the following directory structure:

ingres-ruby-ff-demo
├── doc
│   ├── classes
│   │   └── DatabaseConnection.src
│   ├── files
│   │   └── src
│   ├── images
│   ├── js
│   └── src
├── images
└── src

Database Schema

The demodb schema consists of three tables.

The tables Airport and Airline form master tables, and the Route table is a detail table.

Running the demo

After extracting the demonstration code run the following commands to start the application from the terminal or command prompt:

  • Linux
cd ingres-ruby-ff-demo
./flight_planner.sh
  • Windows
cd ingres-ruby-ff-demo
flight_planner.bat

Screenshots

After starting the application you'll see the following dialogue if the application was able to connect to Ingres:

If the application was unable to connect to Ingres you'll be taken to the Connect screen:

If you wish to connect to a remote installation, simply provide the following information:

  • hostname or IP address of the server instance
  • listen address of the server instance
  • username and password
  • database name, unless directed otherwise this should be demodb

Clicking on Change' the application will attempt to connect with the new settings. If you wish to make the application use these settings again, check the box labelled Make defined source default.

Searching for a particular route requires you select a departure country and airport, along with the destination country and airport. Clicking Go will provide the flight details for the search criteria.

Going to the Profile screen we can create new profiles:

or browse existing profiles (Note that the Chinese characters do not render correctly on Windows this is a known issue)

Known Problems

  • The displaying of Chinese characters does not work with RubyTk on Windows. Instead of seeing 啟文 for the first name in the profile for ac.fan@cool-hvac.net the following is shown:

Image:Ruby Flight Planner - Bad Unicode.png


Bug reports

Any problems you find with the demo can be posted to the Ingres Community forums.

Personal tools
© 2011 Actian Corporation. All Rights Reserved