Page 1 of 1

Cloud database?

Posted: Sun Dec 09, 2018 8:22 pm
by doctorized
Is there a way to have a cloud database used by Windows app? I tried to use Firebase but it seems to be available for mobile devices only. Is there any solution for Windows? If not, could a simple sqlite file be stored somewhere on the web and accessed from my app using PB's integrated SQL support?

Re: Cloud database?

Posted: Sun Dec 09, 2018 10:12 pm
by Paul
doctorized wrote:Is there a way to have a cloud database used by Windows app?
Sure.
In it's simplest form, set up a MariaDB/mySQL or PostgreSQL server somewhere.
Then use PB database commands to access it directly...

Code: Select all

OpenDatabase(0, "host=mydomain.com port=5432", "dbname", "password")
Of course if you want security, better to use this method through a tunnel (SSH).
If you also want to set up your own web server where your database server is located, you can then create a CGI app which talks locally to the database server and the CGI app is the middleman between the database and your main app.

Guess it all depends how involved you want this to become ;)

Re: Cloud database?

Posted: Mon Dec 10, 2018 10:17 am
by NicTheQuick
Do not connect directly to an external database server unless you know exactly what you are doing or the program will never be publicly available. To connect to a database server you need credentials and you can never hide these credentials that good in your executable that nobody can read them. If someone else extracts the credentials from your executable he basically can do all of the things your application is able to do or more. It depends on how well you configured your database server.
Always develop a server side service which is the only one that has access to the database server and provides an API which can be called from your application. The API should only be accessible from someone who had registered to use your application so you can exactly manage which calls he can make to the database.

Re: Cloud database?

Posted: Mon Dec 10, 2018 11:08 am
by doctorized
Here is the point. I have some co-workers to share some data and I want a database somewhere in cloud so the data can be available wherever they are. Everyone will have his own user name and password to access them. I know that the best way is to have the base somewhere stored and a web service to read/write. Then, my app will communicate with that service using TLS. I do not know hot to implement something like that and I do not have the time to do it. I cannot spend money to buy a solution so I am asking for something "ready" like Firebase. Unfortunately, the devices will be desktop and laptop computers and not tablets or smartphones to create android app.

Re: Cloud database?

Posted: Mon Dec 10, 2018 11:49 am
by NicTheQuick
Why not using a normal database browser like DBeaver or DB Browser for SQLite or something similar then? If you define strong passwords for every user and use some SSL tunnels that would be the simplest solution.

Re: Cloud database?

Posted: Mon Dec 10, 2018 1:52 pm
by doctorized
NicTheQuick wrote:Why not using a normal database browser like DBeaver or DB Browser for SQLite or something similar then? If you define strong passwords for every user and use some SSL tunnels that would be the simplest solution.
As I saw, the second one just creates and edits the db, right? The first one does pretty much the same or I understood wrong?

Re: Cloud database?

Posted: Mon Dec 10, 2018 6:35 pm
by the.weavster
doctorized wrote:Here is the point. I have some co-workers to share some data and I want a database somewhere in cloud so the data can be available wherever they are. Everyone will have his own user name and password to access them. I know that the best way is to have the base somewhere stored and a web service to read/write. Then, my app will communicate with that service using TLS. I do not know hot to implement something like that and I do not have the time to do it. I cannot spend money to buy a solution so I am asking for something "ready" like Firebase. Unfortunately, the devices will be desktop and laptop computers and not tablets or smartphones to create android app.
You can use a regular hosting service and PB's CGI + JSON commands to create an API. SpiderBasic will be best for the client UI because then it won't matter whether client devices are desktops, laptops or tablets.

I like 4uHosting in the UK because they let you create and access folders above the root folder your website is served from. That means you can put files (e.g. your SQLite database) somewhere you can be sure the webserver won't serve them up but your CGI programs can still read and write to them.

Re: Cloud database?

Posted: Mon Dec 10, 2018 8:03 pm
by doctorized
the.weavster wrote:You can use a regular hosting service and PB's CGI + JSON commands to create an API. SpiderBasic will be best for the client UI because then it won't matter whether client devices are desktops, laptops or tablets.

I like 4uHosting in the UK because they let you create and access folders above the root folder your website is served from. That means you can put files (e.g. your SQLite database) somewhere you can be sure the webserver won't serve them up but your CGI programs can still read and write to them.
In other words, you mean that I can use Spider Basic to create the client UI and not a Windows app. My biggest problem still exists, the creation of the web service. I know that it must have two functionalities, authentication and read/write to the db.

Re: Cloud database?

Posted: Tue Dec 11, 2018 9:42 am
by the.weavster
doctorized wrote:My biggest problem still exists, the creation of the web service.
the.weavster wrote:You can use a regular hosting service and PB's CGI + JSON commands to create an API.

Re: Cloud database?

Posted: Tue Dec 11, 2018 3:46 pm
by fabulouspaul
...you could simply try https://www.obvibase.com/
No need for setting up services... simple access by web browser.

Re: Cloud database?

Posted: Thu Dec 13, 2018 10:03 pm
by doctorized
the.weavster wrote:
doctorized wrote:My biggest problem still exists, the creation of the web service.
the.weavster wrote:You can use a regular hosting service and PB's CGI + JSON commands to create an API.
Sorry, but this answer is not clear enough for me. Where is that "regular hosting service"? The API mentioned will be in the that service?

Re: Cloud database?

Posted: Fri Dec 14, 2018 3:23 pm
by the.weavster
doctorized wrote:Sorry, but this answer is not clear enough for me. Where is that "regular hosting service"?
As if you were going to put up your own website, like this. Just make sure whichever hosting service you choose includes support for CGIs. I also prefer hosts that let you access folders a level above your web root so you can put files out of reach of the web server but still within reach of your CGIs.
doctorized wrote:The API mentioned will be in the that service?
You can use PureBasic's CGI commands to create the API. Once compiled your CGI executables are put in your website's cgi-bin folder.

Let's say you register the domain "yourdomain" for your website, you create a CGI named "yourcgi.exe" and upload it to your cgi-bin. Then you'd send data to it by making a POST httprequest to:
http://www.yourdomain/cgi-bin/yourcgi.exe

If you're making the POST request from a web page hosted on your domain you only need the relative path:
/cgi-bin/yourcgi.exe

If you use SpiderBasic to create the UI you can serialize any data you want to exchange between the SB client and the PB API as JSON.

Re: Cloud database?

Posted: Fri Dec 14, 2018 4:49 pm
by NicTheQuick
Most of the servers out there are running Linux. So you CGI script should also be a Linux executable, not a Windows executable. Also you need to know if it is an x86 or x64 kernel and which libraries are installed on the server so you can use the purebasic libraries you need, for example sqllite libraries.