1

I have been writing a small Python app for several weeks. The application reads data from a Firebird database and it copies it to another DB. I'm using FDB with Firebird embedded.

This is my connection code.

def createConnectionTo(path):
    try:
        connection = fdb.connect(
            database=path,
            user='SYSDBA',
            password='masterkey',
            charset='WIN1252'
        )
        print("Connessione al database riuscita!\n")
        return connection
    except fdb.fbcore.DatabaseError as details:
        errorMsg = "ERRORE: impossibile connettersi al database!\nPer favore scegliere un altro file.\n\nDETTAGLI\n"+str(details).replace("\\n", "\n")+"\n"
        print(errorMsg)
        return False
    except fdb.fbcore.ProgrammingError as details:
        errorMsg = "ERROR: bad parameters value!\nPlease check your connection code.\nDETAILS: "+str(details)+"\n"
        print(errorMsg)
        return False
    except Exception as errorMsg:
        print("ERRORE: "+str(errorMsg))
        input("Premi un ENTER per chiudere la finestra.")
        return -1

This code works for folders inside my computer, but inexplicably it doesn't work for folders shared in our local network. I used os.path.exists() to check whetever Python was able to find the selected shared folders and it always returned True.

I keep getting this error and I don't have any clue how to solve it, even if I suspect that it is somewhat related to a slash conversion issue.

('Error while connecting to database:
- SQLCODE: -902
- I/O error during "CreateFile (open)" operation for file "Danea Easyfatt\\ANYMA 2017 dal 06-02-17.eft"
- Error while trying to open file
- Impossibile trovare il percorso specificato. ', -902, 335544344)

I tried all the following way to type the path:

  • \\CENTRALE\Danea Easyfatt\ANYMA 2017 dal 06-02-17.eft
  • //CENTRALE/Danea Easyfatt/ANYMA 2017 dal 06-02-17.eft
  • \\\CENTRALE\\Danea Easyfatt\\ANYMA 2017 dal 06-02-17.eft

None of them worked.

  • your error shows file name ending with .EFT - why do you think that file type is Firebird database ??? https://www.solvusoft.com/en/file-extensions/file-extension-eft/ – Arioch 'The Feb 06 '18 at 17:36
  • @Arioch'The in this case EFT stands for Easyfatt, the management software used in the company where I work. The software house responsabile for Easyfatt assured me that it is just a renamed Firebird database. –  Feb 08 '18 at 13:36
  • Now, show please the database connection string ( the path variable, probably ) as you constructed it before `fdb.connect` call. As of the error text suggest not the network path, but instead the subfolder in the "current working directory" of your application. If you would set SysInternals Process Monitor to monitor your application you would probably see where it really tries to open the database file - and it is NOT a network share most probably. – Arioch 'The Feb 08 '18 at 15:25
  • I'm not sure why you added those paths in your edit just now. All of those are network share paths, but in this case, it looks like you may have actually connected to a Firebird server on the machine `CENTRALE` (using Firebird's XNET protocol), but instructed it to connect to the local filesystem file with relative path `Danea Easyfatt\ANYMA 2017 dal 06-02-17.eft`, which doesn't exist from the perspective of the local file system. – Mark Rotteveel Feb 09 '18 at 16:40
  • The XNET protocol uses a connection string that looks like a UNC path if used with a relative path or an alias. – Mark Rotteveel Feb 09 '18 at 16:48
  • `\\CENTRALE\Danea Easyfatt\ANYMA 2017 dal 06-02-17.eft` - this is a WNET ( Microsoft Named Pipes ) connection, which is very rarely used and is going to be removed from FB. Read firebird manuals about making a string for INET (TCP/IP 4) connection attempt – Arioch 'The Feb 12 '18 at 11:32
  • Thank you all for the precious info. I tried using `\\CENTRALE` with an absolute path and it worked (`\\CENTRALE\C:\Users\etc.eft`). However my problem remains, because I would like to get the path from an open file dialog interface, which returns only an UNC path. Right now I'm working on converting an UNC path to the "real" absolute one. But this is another issue, for another question. ;) –  Feb 13 '18 at 09:16
  • Did you manage to connect to the Firebird Database? Is your project available somewhere (maybe Github)? – LukeSavefrogs Apr 20 '23 at 14:24

1 Answers1

4

You cannot access databases on a network share. Firebird explicitly disallows this*. However, as far as I can tell, the error you display simply means you're trying to use an invalid path to access file.

If you want to connect to a Firebird database over a network, you should connect to a Firebird server on the system hosting the database. That means running Firebird server, not using Firebird Embedded.

* : You can configure Firebird to allow opening database on a network drive, but it is a great way to corrupt a database if multiple processes try to modify the database from different hosts, it is something you really should not do.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
  • Where can I find the docs on connecting to the Firebird server on the system hosting the database? Thank you very much. :) –  Feb 06 '18 at 14:05
  • @matteobin Just consult the fdb documentation, eg the [quick-start](http://pythonhosted.org/fdb/getting-started.html#quick-start-guide) shows how to connect to a remote host. – Mark Rotteveel Feb 06 '18 at 14:12
  • I did that, but I'm not able to connect to my server. I get the "Unable to complete network request to host" error. Oh well, I'll work on something else and I will come back to this issue later. Thank you very much for now. –  Feb 06 '18 at 14:37
  • @matteobin Then either there is no Firebird server running, it's running on a different port than the default, or it only allows connections from localhost (either by its own config or through a firewall config). – Mark Rotteveel Feb 07 '18 at 09:27
  • Also, @matteobin , how did it end that firebird database file is available on the network shared folder ? Was it your deed, or are those software vendors who did it ? Cause it is bad for both security and data integrity - sharing the database file provides for copying it away, and the copy would lack any security and potentially lack half of data. It is kind of rather wrong setup! – Arioch 'The Feb 08 '18 at 15:22
  • @Arioch'The it was not my deed, it was my company's. They had been using this setup before I came here and they still don't want to change it. –  Feb 11 '18 at 09:18