问题
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