简体   繁体   English

使用PHP访问远程服务器中的sqlite数据库文件

[英]Access sqlite database file in a remote server with PHP

Is it possible to access a sqlite database file in a remote server with PHP? 是否可以使用PHP在远程服务器中访问sqlite数据库文件? I have enabled read access on the databse.db file and tried this: 我已启用对databse.db文件的读取访问权限,并尝试了以下操作:

$dbconn = new SQLite3("http://www.foo.com/database.db");

but it doesn't work: 但它不起作用:

Fatal error: Uncaught exception 'Exception' with message 'Unable to open database: unable to open database file 致命错误:消息为“无法打开数据库:无法打开数据库文件”的未捕获异常“ Exception”

SQLITE is not for this operation, but we can do a trick :) . SQLITE不适用于此操作,但是我们可以做个技巧:)。

  1. create a RESTful server-api that can be put in the remote server to control what you need. 创建一个RESTful服务器API,可以将其放置在远程服务器中以控制所需的内容。
  2. create a RESTful client-api that can be the client you use to connect with the remote RESTful server . 创建一个RESTful client-api,它可以是用于与远程RESTful服务器连接的客户端。

NOTE: this is just for fun as by this trick we created server/client api to simulate server/client db using your programming lang and sqlite :) 注意:这只是为了好玩,因为通过此技巧,我们创建了服务器/客户端api以使用您的编程lang和sqlite来模拟服务器/客户端db :)

I think you can't connect like this. 我认为您无法像这样进行连接。 You can't open the sqlite database which is hosted on remote server, because you may need the update permission of that file. 您无法打开远程服务器上托管的sqlite数据库,因为您可能需要该文件的更新权限。

So you can download that file in your server parametrically then can connect that file which you downloaded. 因此,您可以参数方式将文件下载到服务器中,然后可以连接下载的文件。

Thanks 谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM