2013-05-08 103 views
2

我試圖創建一個遠程系統。相關代碼數據庫如下SQLAlchemy的OperationalError:(OperationalError)無法打開數據庫文件無無

log = core.getLogger() 

engine = create_engine('sqlite:////name:[email protected]/tmp/nwtopology.db',echo=False) 
Base = declarative_base() 
Session = sessionmaker(bind=engine) 
session = Session() 

class SourcetoPort(Base): 
    """""" 
    __tablename__ = 'source_to_port' 
    id = Column(Integer, primary_key=True) 
    port_no  = Column(Integer) 
    src_address = Column(String,index=True) 

    #----------------------------------------- 
    def __init__(self, src_address,port_no): 
     """""" 
     self.src_address = src_address 
     self.port_no  = port_no 

顯然我試圖在創建數據庫給出一個遠程系統。我得到的錯誤:

OperationalError: (OperationalError) unable to open database file None None 

我的問題如下。

1)在本地機器上運行程序的用戶與嘗試在遠程機器上創建數據庫的用戶不同。這是一個問題嗎?

2)是否有任何機制可以通過創建本地緩存副本來改善將條目插入數據庫和查詢和輸入的延遲?

Regards, Karthik。

回答

3

sqlite不能在網絡上使用,使用登錄憑證,就像連接到MySQL或PostgreSQL一樣;正確的連接字符串傳遞給create_engine只是

engine = create_engine('sqlite:////tmp/nwtopology.db') 
+0

我應該怎麼做才能通過網絡創建一個具有登錄憑據的數據庫? – liv2hak 2013-05-08 04:20:12

0

this,你可以使用這個符號提供一些視頻指南:

engine = create_engine('sqlite:///\\\\192.168.129.139\\tmp\\nwtopology.db',echo=False) 

還是做不知道如何傳遞網絡憑證,但至少可以通過這種方式訪問​​遠程文件。它爲我工作。

+1

通過網絡共享使用SQLite非常令人沮喪,請參閱「何時其他RDBMS可能更好地工作」:https://sqlite.org/whentouse.html – 2014-06-30 23:57:33

相關問題