PureBasic Forum
http://forums.purebasic.com/english/

Cloud database?
http://forums.purebasic.com/english/viewtopic.php?f=13&t=71898
Page 1 of 1

Author:  doctorized [ Sun Dec 09, 2018 8:22 pm ]
Post subject:  Cloud database?

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?

Author:  Paul [ Sun Dec 09, 2018 10:12 pm ]
Post subject:  Re: Cloud database?

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:
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 ;)

Author:  NicTheQuick [ Mon Dec 10, 2018 10:17 am ]
Post subject:  Re: Cloud database?

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.

Author:  doctorized [ Mon Dec 10, 2018 11:08 am ]
Post subject:  Re: Cloud database?

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.

Author:  NicTheQuick [ Mon Dec 10, 2018 11:49 am ]
Post subject:  Re: Cloud database?

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.

Author:  doctorized [ Mon Dec 10, 2018 1:52 pm ]
Post subject:  Re: Cloud database?

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?

Author:  the.weavster [ Mon Dec 10, 2018 6:35 pm ]
Post subject:  Re: Cloud database?

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.

Author:  doctorized [ Mon Dec 10, 2018 8:03 pm ]
Post subject:  Re: Cloud database?

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.

Author:  the.weavster [ Tue Dec 11, 2018 9:42 am ]
Post subject:  Re: Cloud database?

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.

Author:  fabulouspaul [ Tue Dec 11, 2018 3:46 pm ]
Post subject:  Re: Cloud database?

...you could simply try https://www.obvibase.com/
No need for setting up services... simple access by web browser.

Author:  doctorized [ Thu Dec 13, 2018 10:03 pm ]
Post subject:  Re: Cloud database?

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?

Author:  the.weavster [ Fri Dec 14, 2018 3:23 pm ]
Post subject:  Re: Cloud database?

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.

Author:  NicTheQuick [ Fri Dec 14, 2018 4:49 pm ]
Post subject:  Re: Cloud database?

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.

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/