<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.dabo.leafe.com/index.php?action=history&amp;feed=atom&amp;title=Firebird</id>
	<title>Firebird - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.dabo.leafe.com/index.php?action=history&amp;feed=atom&amp;title=Firebird"/>
	<link rel="alternate" type="text/html" href="https://wiki.dabo.leafe.com/index.php?title=Firebird&amp;action=history"/>
	<updated>2026-11-22T00:00:35Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.12</generator>
	<entry>
		<id>https://wiki.dabo.leafe.com/index.php?title=Firebird&amp;diff=4047&amp;oldid=prev</id>
		<title>Ed: Created page with &quot;From [http://firebird.sourceforge.net/ http://firebird.sourceforge.net/]: &lt;blockquote&gt; Firebird is a relational database offering many ANSI SQL-92 features that runs on Linux,...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.dabo.leafe.com/index.php?title=Firebird&amp;diff=4047&amp;oldid=prev"/>
		<updated>2020-05-11T16:14:23Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;From [http://firebird.sourceforge.net/ http://firebird.sourceforge.net/]: &amp;lt;blockquote&amp;gt; Firebird is a relational database offering many ANSI SQL-92 features that runs on Linux,...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;From [http://firebird.sourceforge.net/ http://firebird.sourceforge.net/]:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
Firebird is a relational database offering many ANSI SQL-92 features that runs on Linux, Windows, and a variety of Unix platforms. Firebird offers excellent concurrency, high performance, and powerful language support for stored procedures and triggers. It has been used in production systems, under a variety of names since 1981.&lt;br /&gt;
&lt;br /&gt;
Firebird is a commercially independent project of C and C++ programmers, technical advisors and supporters developing and enhancing a multi-platform relational database management system based on the source code released by Inprise Corp (now known as Borland Software Corp) under the InterBase? Public License v.1.0 on 25 July, 2000.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Below are two simple Python scripts (not involving dabo) just showing how to connect to Firebird and do a simple task using wxPython.&lt;br /&gt;
&lt;br /&gt;
(1) The first script lets the user go into the File menu and select a Firebird database, and then it displays (do-nothing) buttons in a wxPython Sizer object down the left side of the window, one for each table (and view) in the database.&lt;br /&gt;
&lt;br /&gt;
(2) The second script is hard-coded to open a particular Firebird database and display a particular table in a grid. (Before running, you will need to go into this script and change the hard-coded sections so they are appropriate for your system. You&amp;#039;ll need to change the host and database parameters and the SQL statement - and maybe also the user and password parameters. Look for the lines preceded by a comment starting with ###.)&lt;br /&gt;
&lt;br /&gt;
Before running these scripts, you&amp;#039;ll need to do the following using instructions available elsewhere on the web.&lt;br /&gt;
&lt;br /&gt;
(a) Install wxPython on your system (typically in the python/lib/site-packages directory).&lt;br /&gt;
&lt;br /&gt;
(b) Install KinterbasDB on your system (typically in the python/lib/site-packages directory)&lt;br /&gt;
&lt;br /&gt;
(c) Install the Firebird open-source database on your system.&lt;br /&gt;
&lt;br /&gt;
(d) Create a Firebird database (*.FDB file).&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
#########################################&lt;br /&gt;
## SCRIPT 1 - Put this in a separate .py file.&lt;br /&gt;
##########################################&lt;br /&gt;
&lt;br /&gt;
# You need to have KinterbasDB and wxPython installed &lt;br /&gt;
# (typically in your python/Lib/site-packages/ directory) for this script to work.&lt;br /&gt;
# This Python script displays a simple window with a simple file-open menu.&lt;br /&gt;
# If you use te file-open menu to navigate to a Firebird database, then it will connect to that database&lt;br /&gt;
# and display a bunch of buttons down the left side of your window in a Sizer wxControl.&lt;br /&gt;
&lt;br /&gt;
# The buttons *don&amp;#039;t* do anything yet. (I&amp;#039;ve only been using Python and wxPython for about a week!)&lt;br /&gt;
# A possible suggested button-click action would be to display the clicked &lt;br /&gt;
# table&amp;#039;s records in a grid in a panel in the main window.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
from wxPython.wx import *&lt;br /&gt;
import kinterbasdb&lt;br /&gt;
import os&lt;br /&gt;
ID_ABOUT = 101&lt;br /&gt;
ID_OPEN = 102&lt;br /&gt;
ID_BUTTON = 110&lt;br /&gt;
ID_EXIT = 9999&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class MainWindow(wxFrame):&lt;br /&gt;
    def __init__(self,parent,wxID_ANY,title):&lt;br /&gt;
        self.dirname=&amp;#039;&amp;#039;&lt;br /&gt;
        wxFrame.__init__(self,&lt;br /&gt;
                         parent,&lt;br /&gt;
                         wxID_ANY,&lt;br /&gt;
                         title,&lt;br /&gt;
                         style=wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE)&lt;br /&gt;
        self.control = wxTextCtrl(self,1,style=wxTE_MULTILINE)&lt;br /&gt;
        self.CreateStatusBar()&lt;br /&gt;
        fileMenu=wxMenu()&lt;br /&gt;
        fileMenu.Append(ID_OPEN,&amp;quot;&amp;amp;Open&amp;quot;,&amp;quot; Open a file to edit&amp;quot;)&lt;br /&gt;
        fileMenu.AppendSeparator()&lt;br /&gt;
        fileMenu.Append(ID_ABOUT,&amp;quot;&amp;amp;About&amp;quot;,&amp;quot; Information about this program&amp;quot;)&lt;br /&gt;
        fileMenu.AppendSeparator()&lt;br /&gt;
        fileMenu.Append(ID_EXIT, &amp;quot;E&amp;amp;xit&amp;quot;,&amp;quot; Terminate the program&amp;quot;)&lt;br /&gt;
        menuBar=wxMenuBar()&lt;br /&gt;
        menuBar.Append(fileMenu,&amp;quot;&amp;amp;File&amp;quot;)&lt;br /&gt;
        self.SetMenuBar(menuBar)&lt;br /&gt;
        EVT_MENU(self,ID_ABOUT,self.OnAbout)&lt;br /&gt;
        EVT_MENU(self,ID_EXIT,self.OnExit)&lt;br /&gt;
        EVT_MENU(self,ID_OPEN,self.OnOpen)&lt;br /&gt;
        self.sizer=wxBoxSizer(wxHORIZONTAL)&lt;br /&gt;
        self.sizer2 = wxBoxSizer(wxVERTICAL)&lt;br /&gt;
        self.buttons=[]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        # Use some sizers to see layout options&lt;br /&gt;
        self.sizer.Add(self.sizer2,0,wxEXPAND)&lt;br /&gt;
        self.sizer.Add(self.control,1,wxEXPAND)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        #Layout sizers&lt;br /&gt;
        self.SetSizer(self.sizer)&lt;br /&gt;
        self.SetAutoLayout(1)&lt;br /&gt;
        self.sizer.Fit(self)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        self.Show(1)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    def OnAbout(self,e):&lt;br /&gt;
        d=wxMessageDialog(self,&amp;quot;A sample editor \n&amp;quot;&lt;br /&gt;
                          &amp;quot; in wxPython&amp;quot;,&amp;quot;About Sample Editor&amp;quot;, wxOK)&lt;br /&gt;
        d.ShowModal()&lt;br /&gt;
        d.Destroy()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    def OnExit(self,e):&lt;br /&gt;
        self.Close(true)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    def OnOpen(self,e):&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot; (self:MainWindow,e:Event) Open a Firebird database file *.FDB &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        dlg=wxFileDialog(self,&amp;quot;Choose a Firebird database *.FDB&amp;quot;, self.dirname,&amp;quot;&amp;quot;,&amp;quot;*.FDB&amp;quot;,wxOPEN)&lt;br /&gt;
        if dlg.ShowModal() == wxID_OK:&lt;br /&gt;
            self.filename=dlg.GetFilename()&lt;br /&gt;
            self.dirname=dlg.GetDirectory()&lt;br /&gt;
            # f=open(os.path.join(self.dirname,self.filename),&amp;#039;r&amp;#039;)&lt;br /&gt;
        dlg.Destroy&lt;br /&gt;
        # self.control.SetValue(f.read())&lt;br /&gt;
        # f.close&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        # Some debugging code here, to make sure we&amp;#039;ve got the pathname right... &lt;br /&gt;
        print self.dirname + &amp;quot;\\&amp;quot; + self.filename&lt;br /&gt;
        ### HERE&amp;#039;S WHERE YOU CONNECT TO YOUR FIREBIRD DATABSE (THIS WAS DONE ON WINDOWS).&lt;br /&gt;
        ### YOU MAY NEED TO FIDDLE WITH &amp;#039;/&amp;#039; VERSUS &amp;#039;\&amp;#039; IF YOU&amp;#039;RE ON LINUX.&lt;br /&gt;
        self.cxn = kinterbasdb.connect(host=&amp;#039;localhost&amp;#039;,database=self.dirname + &amp;quot;\\&amp;quot; + self.filename,&lt;br /&gt;
                                        user=&amp;#039;sysdba&amp;#039;,password=&amp;#039;masterkey&amp;#039;)&lt;br /&gt;
        self.sel = &amp;quot;SELECT RDB$RELATION_NAME FROM RDB$RELATIONS \&lt;br /&gt;
        WHERE RDB$RELATION_NAME NOT STARTING WITH &amp;#039;RDB$&amp;#039; ORDER BY RDB$RELATION_NAME&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        self.cur = self.cxn.cursor()&lt;br /&gt;
        self.cur.execute(self.sel)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        for b in self.buttons:&lt;br /&gt;
            self.sizer2.Remove(b)&lt;br /&gt;
            b.Destroy()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        self.buttons = []&lt;br /&gt;
        self.ix=0&lt;br /&gt;
        for t in self.cur:&lt;br /&gt;
            self.buttons.append(wxButton(self,ID_BUTTON+self.ix,t[0].strip()))&lt;br /&gt;
            self.sizer2.Add(self.buttons[self.ix],1,wxEXPAND)&lt;br /&gt;
            self.ix=self.ix+1&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        self.sizer.Fit(self)&lt;br /&gt;
        self.Show(1)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
app = wxPySimpleApp()&lt;br /&gt;
frame = MainWindow(None,-1,&amp;quot;Sample Editor with Sizer with Tables&amp;quot;)&lt;br /&gt;
frame.Show(1)&lt;br /&gt;
app.MainLoop()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#########################################&lt;br /&gt;
## SCRIPT 2 - Put this in a separate .py file.&lt;br /&gt;
##########################################&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Make sure have KinterbasDB and wxPython installed on your machine &lt;br /&gt;
# (typically in your python/Lib/site-packages/ directory) &lt;br /&gt;
# so the &amp;#039;import&amp;#039; calls will work.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# This is a very primitive Python script that displays a Firebird table&amp;#039;s records in a HugeTableGrid.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# The user gets the *impression* that they&amp;#039;re editing the records in the grid,&lt;br /&gt;
# but unfortunately the edits are *not* currently sent back to the Firebird database yet.&lt;br /&gt;
# (I need to write some &amp;quot;SQL builder&amp;quot; code to do that.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# YOU NEED TO MODIFY THIS SCRIPT BEFORE IT WILL RUN ON YOUR MACHINE BECAUSE&lt;br /&gt;
# THE PATHNAME TO THE FIREBIRD DATABASE AND THE NAME OF THE TABLE &lt;br /&gt;
# TO OPEN ARE CURRENTLY HARD-CODED IN THIS SCRIPT.&lt;br /&gt;
# Look for the two lines set of by comments starting with triple-pound-signs ### below - &lt;br /&gt;
# those are the lines you need to modify.&lt;br /&gt;
# I&amp;#039;ve only been using Python and wxPython for about a week, &lt;br /&gt;
# so this script is just &amp;quot;proof of concept&amp;quot; to connect to Firebird.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
import  wx&lt;br /&gt;
import wx.grid as  gridlib&lt;br /&gt;
import kinterbasdb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
 &lt;br /&gt;
class HugeTable(gridlib.PyGridTableBase): &lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot; &lt;br /&gt;
    This is all it takes to make a custom data table to plug into a &lt;br /&gt;
    wxGrid.  There are many more methods that can be overridden, but &lt;br /&gt;
    the ones shown below are the required ones.  This table simply &lt;br /&gt;
    provides strings containing the row and column values. &lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot; &lt;br /&gt;
    def __init__(self, log): &lt;br /&gt;
        gridlib.PyGridTableBase.__init__(self) &lt;br /&gt;
        self.log = log &lt;br /&gt;
        self.odd=gridlib.GridCellAttr() &lt;br /&gt;
        self.odd.SetBackgroundColour(&amp;#039;#FFCCFF&amp;#039;) &lt;br /&gt;
        self.even=gridlib.GridCellAttr() &lt;br /&gt;
        self.even.SetBackgroundColour(&amp;#039;#FFFFCC&amp;#039;)&lt;br /&gt;
        ### YOU NEED TO EDIT THE host AND database (AND LIKELY THE user AND password) VALUES&lt;br /&gt;
        ### IN THE FOLLOWING STATEMENT FOR *YOUR* ENVIRONMENT.&lt;br /&gt;
        self.cxn = kinterbasdb.connect(host=&amp;#039;localhost&amp;#039;,&lt;br /&gt;
                                       database=&amp;#039;e:/firebird/isis/isis_1.fdb&amp;#039;,&lt;br /&gt;
                                       user=&amp;#039;sysdba&amp;#039;,&lt;br /&gt;
                                       password=&amp;#039;masterkey&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        ### YOU NEED TO EDIT THE select STATEMENT BELOW FOR *YOUR* ENVIRONMENT.&lt;br /&gt;
        self.sel = &amp;quot;select * from Invoice&amp;quot;&lt;br /&gt;
        self.curs = self.cxn.cursor()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        self.curs.execute(self.sel)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        # We call list(...) inside the list comprehension [...] to change from list of tuples to list of lists.&lt;br /&gt;
        # This is needed because the data will be edited, and the tuples returned by fetchall(...) aren&amp;#039;t mutable.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        self.data = [list(i) for i in self.curs.fetchall()]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        # Note: This PyGridTableBase does NOT update the Firebird database with the user&amp;#039;s edits.&lt;br /&gt;
        # This will require additional code which builds an UPDATE statement based on the user&amp;#039;s edits.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        # By the way, this self.data property above - a list of lists - &lt;br /&gt;
        # is a simple example of what www.dabodev.com calls a &amp;#039;bizobj&amp;#039;.&lt;br /&gt;
        # I am new to 3-tier programming (former Access programmer here) &lt;br /&gt;
        # but I&amp;#039;m starting to understand the need for &amp;#039;3-tier&amp;#039;:&lt;br /&gt;
        # You simply need a place on the local machine to store the data &lt;br /&gt;
        # you&amp;#039;re displaying until you&amp;#039;re ready to send it back to the backend.&lt;br /&gt;
        # I&amp;#039;m reading an O&amp;#039;Reilly book called &amp;#039;J2EE Design Patterns&amp;#039; which &lt;br /&gt;
        # has a pretty good explanation of Business Objects.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    def GetAttr(self, row, col, kind): &lt;br /&gt;
        attr = [self.even, self.odd][row % 2] &lt;br /&gt;
        attr.IncRef() &lt;br /&gt;
        return attr&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    def GetNumberRows(self):&lt;br /&gt;
        return len(self.data) + 1&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    def GetNumberCols(self):&lt;br /&gt;
        return len(self.data[0])&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    def IsEmptyCell(self, row, col):&lt;br /&gt;
        try:&lt;br /&gt;
            return not self.data[row][col]&lt;br /&gt;
        except IndexError:&lt;br /&gt;
            return 1&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    def GetValue(self, row, col):&lt;br /&gt;
        try:&lt;br /&gt;
            return self.data[row][col]&lt;br /&gt;
        except IndexError:&lt;br /&gt;
            return &amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    def SetValue(self, row, col, value):&lt;br /&gt;
        try:&lt;br /&gt;
            self.data[row][col] = value&lt;br /&gt;
        except IndexError:&lt;br /&gt;
            # add a new row&lt;br /&gt;
            self.data.append([&amp;#039;&amp;#039;] * self.GetNumberCols())&lt;br /&gt;
            self.SetValue(row, col, value)&lt;br /&gt;
            # tell the grid we&amp;#039;ve added a row&lt;br /&gt;
            msg = wxGridTableMessage(self,                             # The table&lt;br /&gt;
                                     wxGRIDTABLE_NOTIFY_ROWS_APPENDED, # what we did to it&lt;br /&gt;
                                     1)                                # how many&lt;br /&gt;
            # I DON&amp;#039;T KNOW IF THE ABOVE STATEMENT WORKS OR WHAT IT&amp;#039;S SUPPOSED TO DO - &lt;br /&gt;
            # I JUST FOUND IT IN SOME CODE. &lt;br /&gt;
            self.GetView().ProcessTableMessage(msg)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    def GetColLabelValue(self,col):&lt;br /&gt;
        # I actually wrote the following line MYSELF! It figures out the column heads for the grid,&lt;br /&gt;
        # based on the .description attribute of the Firebird Cursor&lt;br /&gt;
        return [x[0] for x in self.curs.description][col].title()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
 &lt;br /&gt;
class HugeTableGrid(gridlib.Grid): &lt;br /&gt;
    def __init__(self, parent, log): &lt;br /&gt;
        gridlib.Grid.__init__(self, parent, -1) &lt;br /&gt;
        table = HugeTable(log) &lt;br /&gt;
        # The second parameter means that the grid is to take ownership of the &lt;br /&gt;
        # table and will destroy it when done.  Otherwise you would need to keep &lt;br /&gt;
        # a reference to it and call it&amp;#039;s Destroy method later. &lt;br /&gt;
        self.SetTable(table, True) &lt;br /&gt;
        self.Bind(gridlib.EVT_GRID_CELL_RIGHT_CLICK, self.OnRightDown)&lt;br /&gt;
    def OnRightDown(self, event): &lt;br /&gt;
        print &amp;quot;hello&amp;quot; &lt;br /&gt;
        print self.GetSelectedRows() &lt;br /&gt;
#&lt;br /&gt;
 &lt;br /&gt;
class TestFrame(wx.Frame): &lt;br /&gt;
    def __init__(self, parent, log): &lt;br /&gt;
        wx.Frame.__init__(self, parent, -1, &amp;quot;Huge (virtual) Table Demo&amp;quot;, size=(800,600)) &lt;br /&gt;
        grid = HugeTableGrid(self, log) &lt;br /&gt;
        # grid.SetReadOnly(5,5, True) &lt;br /&gt;
#&lt;br /&gt;
 &lt;br /&gt;
import sys &lt;br /&gt;
app = wx.PySimpleApp() &lt;br /&gt;
frame = TestFrame(None, sys.stdout) &lt;br /&gt;
frame.Show(True) &lt;br /&gt;
app.MainLoop() &lt;br /&gt;
#&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This hasn&amp;#039;t been updated in a while. Stay tuned&lt;/div&gt;</summary>
		<author><name>Ed</name></author>
	</entry>
</feed>