Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connect to SQLite database located in Google Drive from PHP

I think the question says it all. Since PHP5 we have a lot of methods for SQLite database handling. Now I have uploaded a SQLite file to my Google Drive Folder and granted read and write access for all to it. Is it now possible for me to connect to this database file from PHP with functions like:

$dbconn = sqlite_open($googleDriveLink); // or
$db = new SQLite3($googleDriveLink);
like image 764
Cilenco Avatar asked Apr 08 '26 03:04

Cilenco


2 Answers

Read and write access in the context of google drive, means "read and write using their User Interface or APIs", on the other hand, PHP needs "Operating System's read and write access" to the file. Google is not exposing the file in a way that SqLite can handle it. The most best that perhaps in a tricky way, you can obtain is a download and an upload of it, but will collide with others and wont be useful.

like image 98
Luis Siquot Avatar answered Apr 09 '26 17:04

Luis Siquot


You may want to educate yourself on Google Drive's API reference, specifically its section about Files.

You could pass it the download URL, as I assume that's what you mean by $googleDriveLink, but I don't think that's what you're looking for. Say, for example, privacy settings on the file are changed that don't allow anonymous downloads.

To take advantage of the Google Drive APIs in PHP, you'll need to leverage an HTTP client in your code that handles the communication, that or create a backend that your PHP code uses. It may be beneficial to read the Google API PHP Client Library's getting started document.

In whichever path you choose, you'll more than likely have to download the SQLite file to your PHP server and manipulate it locally, and then optionally update it on Google Drive.

Hope that helps.

like image 26
Carl Bennett Avatar answered Apr 09 '26 17:04

Carl Bennett



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!