Connecting to Firebird database from Windows local network

独自空忆成欢 提交于 2019-12-02 15:01:16

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/48644672/connecting-to-firebird-database-from-windows-local-network

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!