Embedded Firebird

385 views
Skip to first unread message

villas

unread,
Sep 2, 2009, 7:16:28 AM9/2/09
to web2py-users
Has anyone found a way of connecting to embedded firebird? I want to
put a total web2py development environment including firebird on my
USB stick.

I have copied all the DLLs into the directory and web2py detects that
'interbase' is present on start-up. However, I just cannot seem to
find a way of connecting to the local fdb file. I feel that I'm just
missing one small detail.

mdipierro

unread,
Sep 2, 2009, 8:22:52 AM9/2/09
to web2py-users
If you find out let us know.

Jose

unread,
Sep 2, 2009, 10:22:12 AM9/2/09
to web2py-users
Never use the embedded version. You tried to put localhost or
127.0.0.1 as the server?

Jose

Jose

unread,
Sep 2, 2009, 10:25:47 AM9/2/09
to web2py-users


On 2 sep, 11:16, villas <villa...@gmail.com> wrote:

villas

unread,
Sep 3, 2009, 11:09:39 AM9/3/09
to web2py-users
> Never use the embedded version. You tried to put localhost or
> 127.0.0.1 as the server?

Hi José, Yes, but then it tries to connect to a running FB server. I
wish to avoid having to run a server and simply connect directly to
the database file (in a similar way that Sqlite does). The connect
string should just be the database name, e.g. c:\data\example.fdb.

I've tried using kinterbasdb.connect directly from the web2py python
shell too, but that doesn't work either. I also following
instructions to make an 'embedded' subdirectory as in 'site-packages
\kinterbasdb\embedded' and put all the firebird files in there. Maybe
it's just problem specific to kinterbase 3.3 and FB 2.1.

I'd love to have been able to get it working. However, unless anyone
has any more tips, I'll have to give up for now :-(

Thanks for responding.

Jose

unread,
Sep 3, 2009, 2:15:41 PM9/3/09
to web2py-users


On 3 sep, 15:09, villas <villa...@gmail.com> wrote:
> > Never use the embedded version. You tried to put localhost or
> > 127.0.0.1 as the server?
>
> Hi José,  Yes, but then it tries to connect to a running FB server.  I
> wish to avoid having to run a server and simply connect directly to
> the database file (in a similar way that Sqlite does).  The connect
> string should just be the database name,  e.g. c:\data\example.fdb.
>


What gives this result?

db = DAL('firebird://sysdba:mast...@127.0.0.1/c:\data\example.fdb')

Jose

villas

unread,
Sep 3, 2009, 3:02:34 PM9/3/09
to web2py-users
> What gives this result?
> db = DAL('firebird://sysdba:master...@127.0.0.1/c:\data\example.fdb')

This connects fine when an fb server is running:
db = DAL('firebird://SYSDBA:mast...@127.0.0.1/k:/web2py/
fbembed.fdb')

but, when I stop the fb server and try to connect, I get this error:

OperationalError: (-902, 'isc_attach_database: \n Unable to
complete network
request to host "127.0.0.1".\n Failed to establish a connection.\n
No connection
could be made because the target machine actively refused it.')

However, this is not surprising; here is a note from the readme file
distributed with the embedded version:

2.2. Database access

Client access can be only via the local protocol,
i.e. NOT a TCP/IP connection string that includes
the server name "localhost" or IP address 127.0.0.1.

The embedded server supports only the local connect
to a database file path without a server name. The
client program gets an exclusive access to the
database file after successful connect.


Jose

unread,
Sep 3, 2009, 6:11:11 PM9/3/09
to web2py-users


On 3 sep, 19:02, villas <villa...@gmail.com> wrote:

> No connection
>   could be made because the target machine actively refused it.')
>

try to change the line 868 of file /gluon/sql.py
kinterbasdb.connect (dsn = '%s:%s'%(host, db)

by

kinterbasdb.connect (dsn = '%s'% db,

and log in just as before:
db = DAL ( 'firebird: / / sysdba: master ... @ 127.0.0.1 / c: \ data \
example.fdb')


If it works, then we'll see how to make a patch.

Jose

villas

unread,
Sep 3, 2009, 9:50:56 PM9/3/09
to web2py-users
@Jose

I tried what you said, it now accepts the strings but it does not
find the database:
OperationalError: (-904, 'isc_attach_database: \n unavailable
database')

I then tried to work directly with kinterbasdb. However, no matter
what I did, I couldn't get any success.
e.g.
>>>import kinterbasdb
>>>con = kinterbasdb.connect(host='', database='k:/web2py/fbembed.fdb',user='sysdba', password='masterkey')
etc, etc

If kinterbasdb does not work directly, then I guess that changing
web2py will not help :-(

BTW I'm trying to get my entire environment incl. embedded Firebird
onto a USB memory stick. Therefore I'm not using the source version
and it makes it more difficult to fiddle around although I've now
discovered that replacing the .pyc files with .py files in library.zip
still seems to work.

Best regards, David

Jose

unread,
Sep 3, 2009, 10:08:36 PM9/3/09
to web2py-users


On 4 sep, 01:50, villas <villa...@gmail.com> wrote:

>
> If kinterbasdb does not work directly,  then I guess that changing
> web2py will not help :-(


It does not help much, but seen this?

http://kinterbasdb.sourceforge.net/dist_docs/usage.html#faq_fep_embedded_using_with

Jose

Jose

unread,
Sep 3, 2009, 10:19:58 PM9/3/09
to web2py-users


On 4 sep, 01:50, villas <villa...@gmail.com> wrote:

> I then tried to work directly with kinterbasdb.  However, no matter
> what I did,  I couldn't get any success.
> e.g.>>>import kinterbasdb
> >>>con = kinterbasdb.connect(host='', database='k:/web2py/fbembed.fdb',user='sysdba', password='masterkey')
>

change by
con = kinterbasdb.connect(host='', database=r'k:\web2py
\fbembed.fdb',user='sysdba', password='masterkey')

jose

villas

unread,
Sep 4, 2009, 6:24:36 AM9/4/09
to web2py-users
> change by
> con = kinterbasdb.connect(host='', database=r'k:\web2py
> \fbembed.fdb',user='sysdba', password='masterkey')

José,
You rock man! I never tried the little 'r'. So maybe now there is a
way!

I didn't play around with it so much yet, but I suppose the web2py
regex which checks the firebird connect string needs some tickering.

Perhaps better still, maybe web2py could have another DAL connect
type, e.g. 'firebirdembed'. I guess this would be easy to implement
and maintain. In some ways it would be better to completely separate
this connection because it would have significantly different
characteristics and usage (single-user, no security etc). What do
you think?
D

villas

unread,
Sep 7, 2009, 10:17:59 AM9/7/09
to web2py-users
Jose has found a Firebird Embedded connect string which works with
kinterbasdb. I would like to be able to add it somehow to sql.py so
that we can use the string in DAL.

I have spent a while trying, but I wasn't able to make the DAL work.
I'm not even sure that I am going about it in the right way.

I'm really sorry that I can't seem to successfully help myself, but
being rather new to Web2py and Python I just don't seem to have enough
expertise.

Can anyone give me a couple of pointers? Should I simply concentrate
on the DAL regex string, or should I try to make another database
type. Host and port do not need to be specified (and I think that
user and password are redundant too), dialect could be assumed to be
3, but charset also necessary. Maybe something like this... (I do
not know how to specify the quotes etc):

db = DAL('firebird://r'c:/data/example.fdb';set_encoding=('UTF8')')

Thanks to Jose for his help so far!

mdipierro

unread,
Sep 7, 2009, 10:58:43 AM9/7/09
to web2py-users
In trunk try

DAL('firebird_embedded://sysdba:masterkey@k:\\web2py\\fembed.fdb')

villas

unread,
Sep 7, 2009, 2:55:11 PM9/7/09
to web2py-users
@Massimo
Yes it worked! BTW I used forward slashes in the path (just because
it seems to work and is easier to type).

I can now work from a USB stick and deploy in seconds to a full
Firebird client/server database; how cool is that!
Thanks for all your help.
David

mdipierro

unread,
Sep 7, 2009, 3:00:43 PM9/7/09
to web2py-users
Very cool!

mdipierro

unread,
Sep 7, 2009, 4:01:59 PM9/7/09
to web2py-users
I am not convinced this is the best syntax so if people have a better
idea that starts with 'firebird://' and can parse both normal uri and
embedded uri, let me know.
Reply all
Reply to author
Forward
0 new messages