Issue Details (XML | Word | Printable)

Key: PYFB-23
Type: Bug Bug
Status: Closed Closed
Resolution: Won't Fix
Priority: Major Major
Assignee: Pavel Cisar
Reporter: Baskin Tapkan
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Firebird driver for Python

Running "python setup.py install" returns an error.

Created: 11/Oct/12 01:46 PM   Updated: 12/Oct/12 08:59 AM
Component/s: None
Affects Version/s: 0.9
Fix Version/s: None

Environment: Windows x64-bit and MacOS 10.7 Snowleopard


 Description  « Hide
Have tried running the "python setup.py install" command on two different systems. I am getting the below error on both. Would you please help? Thanks.

c:\src\python\fdb-0.9.1>python setup.py install
Traceback (most recent call last):
  File "setup.py", line 7, in <module>
    from fdb import __version__
  File "c:\src\python\fdb-0.9.1\fdb\__init__.py", line 23, in <module>
    from fdb.fbcore import *
  File "c:\src\python\fdb-0.9.1\fdb\fbcore.py", line 26, in <module>
    from . import ibase
  File "c:\src\python\fdb-0.9.1\fdb\ibase.py", line 39, in <module>
    fb_library = WinDLL(fb_library_name)
  File "C:\Python27\lib\ctypes\__init__.py", line 353, in __init__
    self._handle = _dlopen(self._name, mode)
TypeError: expected string or Unicode object, NoneType found



 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Philippe Makowski added a comment - 11/Oct/12 01:58 PM
you should post this kind of question on the support list firebird-python@yahoogroups.com

I guess that you don't have Firebird client library on your system
fdb need the Firebird client lib
 

Baskin Tapkan added a comment - 11/Oct/12 06:54 PM
sent the below email (awaiting moderator's approval). Thanks for the tip.

Hello,

Hope everyone is doing well. Having this problem of not being able to connect to an existing embedded Firebird database using Python.

I work regularly on a Windows 7 x64-bit, Python 2.7 (switched to 2.6 for kinterbasdb w/o success, then switch back). I also have a licensed copy of Firebird Maestro. Tried three different library packages:

firebirdsql (relatively new, but does not seem to have support for embedded) (http://pypi.python.org/pypi/firebirdsql)

kinterbasdb (last update was in 2010, seemed to install) (

fdb (could not install either on Windows or MacOS).(http://pypi.python.org/pypi/fdb)

have the bellow code (basically trying to invoke the sample code on the documentation:

# import firebirdsql
import kinterbasdb

# the server is named test.fsdb
# con = firebirdsql.connect(dsn='TEST.FDB', user='SYSDBA', password='masterkey')
con = kinterbasdb.connect(host='', database=r'C:\src\python\pyfirebirdsql\TEST.FDB',user='sysdba', password='masterkey')

cur = con.cursor()

# execute the select statement
cur.execute("select * from languages order by year_released")

# retrieve all rows in a sequence and print the sequence
print cur.fetchall()

TEST.FDB file is in the same directory as I am running the script. With firebirdsql package, I receive below:

c:\src\python\pyfirebirdsql>python fsdb_test.py
Traceback (most recent call last):
  File "fsdb_test.py", line 5, in <module>
    con = firebirdsql.connect(dsn='TEST.FDB', user='SYSDBA', password='masterkey')
  File "c:\src\python\pyfirebirdsql\firebirdsql\__init__.py", line 64, in connect
    database=database, charset=charset, port=port)
  File "c:\src\python\pyfirebirdsql\firebirdsql\fbcore.py", line 759, in __init__
    self.sock.connect((self.hostname, self.port))
  File "C:\Python27\lib\socket.py", line 224, in meth
    return getattr(self._sock,name)(*args)
socket.error: [Errno 10061] No connection could be made because the target machine actively refused it

Looks like support for embedded is missing for firebirdsql.

With kinterbasdb, I get this:

c:\src\python\pyfirebirdsql>python fsdb_test.py
Traceback (most recent call last):
  File "fsdb_test.py", line 2, in <module>
    import kinterbasdb
  File "C:\Python27\lib\site-packages\kinterbasdb\__init__.py", line 119, in <module>
    import _kinterbasdb as _k
ImportError: DLL load failed: %1 is not a valid Win32 application.

This is 32 bit vs 64-bit issue looks like. I made sure I used both 64-bit editions of Python 2.7 and kinterbasdb-3.3.0. Still getting this message. Created an embedded folder as described here in the Python27\Lib\site-packages\kinterbasdb\embedded and copied the three DLLS (unblocked on Windows).

Could not even install fdb using below command:

c:\src\python\fdb-0.9.1>python setup.py build
Traceback (most recent call last):
  File "setup.py", line 7, in <module>
    from fdb import __version__
  File "c:\src\python\fdb-0.9.1\fdb\__init__.py", line 23, in <module>
    from fdb.fbcore import *
  File "c:\src\python\fdb-0.9.1\fdb\fbcore.py", line 26, in <module>
    from . import ibase
  File "c:\src\python\fdb-0.9.1\fdb\ibase.py", line 39, in <module>
    fb_library = WinDLL(fb_library_name)
  File "C:\Python27\lib\ctypes\__init__.py", line 353, in __init__
    self._handle = _dlopen(self._name, mode)
TypeError: expected string or Unicode object, NoneType found

Just to see if embedded works, I switched to .NET (sigh) and able to connect to the same database using the below:

class Program
    {
        static void Main(string[] args)
        {
            string ConnectionString = "Database=E:\\TEST.FDB;User=SYSDBA;Password=masterkey;Dialect=3;ServerType=1";
            FbConnection addDetailsConnection = new FbConnection(ConnectionString);
            addDetailsConnection.Open();

            Console.WriteLine("connection open");
            Console.ReadLine();
            addDetailsConnection.Close();
            Console.WriteLine("connection closed");
            Console.ReadLine();
        }
 }

For .NET, I followed the detailed and easy-to-follow instructions found here. http://nazmialtun.blogspot.com/2012/01/using-embedded-firebird-database-in-net.html

Any help, expertise with the above would be appreciated. Thanks!

Baskin Tapkan