Firebird News

Tuesday, July 29, 2014

#node.js and #firebird installing on Amazon EC2 instance

Here are the notes on Installing node.js module for firebird
I assume Firebird was installed from source or from tar.gz and in a linux instance (mine is the free one)


wget http://nodejs.org/dist/v0.10.29/node-v0.10.29.tar.gz
tar -zxvf node-v0.10.*.tar.gz
cd node-v0.10.*
./configure 
make ; sudo make install

Next is time to install the firebird module (Firebird was installed from source in /opt/firebird2.5.x)

git clone git://github.com/xdenser/node-firebird-libfbclient.git
cd node-firebird-lib
export PATH=$PATH:/opt/firebird2.5.x/binfbclient/

npm install

create firebird db and test table in /tmp/nodedb.fdb with isql or isql-fb

SQL>CREATE DATABASE "localhost:/tmp/nodedb.fdb" user 'SYSDBA' password '*********';
SQL> CREATE TABLE TEST (ID INT NOT NULL PRIMARY KEY, NAME VARCHAR(20));
SQL> create generator gen_test_id;
SQL> SET GENERATOR gen_test_id TO 10;
SQL> set term !! ;
SQL> CREATE TRIGGER TEST_BI FOR TEST
CON> ACTIVE BEFORE INSERT POSITION 0
CON> AS
CON> BEGIN
CON> if (NEW.ID is NULL) then NEW.ID = GEN_ID(GEN_TEST_ID, 1);
CON> END!!
SQL> set term ; !!

Then write the test.js script to connect to it



you can observe that the id is auto incremented if you run it multiple time

node test.js 
[ { ID: 5, NAME: 'new one' },
  { ID: 11, NAME: 'new one' },
  { ID: 12, NAME: 'new one' },
  { ID: 13, NAME: 'new one' },
  { ID: 14, NAME: 'new one' } ]

also in the name you can put later the
browser or the ip in one of the columns


We build now the version for the web modifying the hello world version adding the firebird database glue



you can run it with
 node firebird_example.js

Tuesday, July 22, 2014

Rails On Firebird - status and follow the guide

Rails On Firebird - you need to check that Firebird active record adapter and ruby driver are installed
Install Rails 4.x :
 gem install rails
Generate a new Firebird Rails application
rails new firebird_app 
delete the generated database.yml sqlite config and use the one from bellow
Be aware about indentation
cat config/database.yml


Edit the project Gemfile and add the activerecord-fb-adapter gem:
gem 'activerecord-fb-adapter'
Then run:
bundle update
 rails generate scaffold Client name:string address:string email:string remark:text
  rake db:migrate
I have re-read the ruby guide
so i did these commands while following the official guide
rake db:create
but database was already created in flamerobin
script/generate controller home index
vi app/views/home/index.html.erb
and write something there, start the server with
rails s
and now you can see something in browser
http://localhost:3000/


I have created the table and one sequence in firebird db
CREATE TABLE posts (
id BIGINT NOT NULL PRIMARY KEY,
name VARCHAR(255),
title VARCHAR(255),
content VARCHAR(255),
timestamps timestamp
);
CREATE sequence POSTS_SEQ;

I have ran the scaffold again to generate the posts model/view/controller
script/generate scaffold Post name:string title:string content:text
and then
started the server
rails s

Of course I have modified the route and added an link as in tutorial and now i can add and modify blog posts
note: in new rails route is defined this way in config/routes.rb
map.root :controller => "home"

http://localhost:3000/posts






Follow the normal ActiveRecord conventions for table names, primary key columns, etc. The one “extra” you’ll need for Firebird is that you’ll have to create a generator for any tables that require a sequence-based primary key. The default naming convention is TABLENAME_SEQ. So if you have a users table, you would need to create a corresponding USERS_SEQ generator

You don't need to create before insert triggers ! rails reads the value from sequence and then increments it in ruby code, Yay!

Wednesday, July 09, 2014

Installing Android x86 4.4 on my eeepc with qemu

In fact is an re-install , i had 4.3 in dual boot with debian sid on my eeepc and i wanted to do an upgrade , the issue is that i don't have a usb stick to boot from it so i took another route

I have installed qemu and then downloaded the 4.4 iso from android x86 site and started this way to detect partitions on the main drive

qemu -boot d -cdrom android-x86-4.4-RC2.iso -hda /dev/sda

 format the partition already prepared in my case 15G /dev/sda4 also do not install grub if you want to modify it manually from debian partition


 After the install is finished you need to test it first that it works i mount /dev/sda4 to see the dir structure
mount /dev/sda4 /mnt
ls /mnt/
android-4.4-RC2  lost+found

so i have modified /etc/grub.d/40_custom this way
 menuentry "Android-x86 4.4" {
set root=(hd0,4) linux /android-4.4-RC2/kernel quiet root=/dev/ram0 androidboot_hardware=eeepc acpi_sleep=s3_bios,s3_mode SRC=/android-4.4-RC2 DATA= initrd /android-4.4-RC2/initrd.img
}

sudo update-grub2


 and restart choose the new android version