Cloud database?

Just starting out? Need help? Post your questions and find answers here.
User avatar
doctorized
Addict
Addict
Posts: 854
Joined: Fri Mar 27, 2009 9:41 am
Location: Athens, Greece

Cloud database?

Post 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?
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1243
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Re: Cloud database?

Post 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 ;)
Image Image
User avatar
NicTheQuick
Addict
Addict
Posts: 1218
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: Cloud database?

Post 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.
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
User avatar
doctorized
Addict
Addict
Posts: 854
Joined: Fri Mar 27, 2009 9:41 am
Location: Athens, Greece

Re: Cloud database?

Post 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.
User avatar
NicTheQuick
Addict
Addict
Posts: 1218
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: Cloud database?

Post 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.
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
User avatar
doctorized
Addict
Addict
Posts: 854
Joined: Fri Mar 27, 2009 9:41 am
Location: Athens, Greece

Re: Cloud database?

Post 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?
User avatar
the.weavster
Addict
Addict
Posts: 1531
Joined: Thu Jul 03, 2003 6:53 pm
Location: England

Re: Cloud database?

Post 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.
User avatar
doctorized
Addict
Addict
Posts: 854
Joined: Fri Mar 27, 2009 9:41 am
Location: Athens, Greece

Re: Cloud database?

Post 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.
User avatar
the.weavster
Addict
Addict
Posts: 1531
Joined: Thu Jul 03, 2003 6:53 pm
Location: England

Re: Cloud database?

Post 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.
fabulouspaul
User
User
Posts: 34
Joined: Sun Nov 23, 2014 1:18 pm

Re: Cloud database?

Post by fabulouspaul »

...you could simply try https://www.obvibase.com/
No need for setting up services... simple access by web browser.
User avatar
doctorized
Addict
Addict
Posts: 854
Joined: Fri Mar 27, 2009 9:41 am
Location: Athens, Greece

Re: Cloud database?

Post 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?
User avatar
the.weavster
Addict
Addict
Posts: 1531
Joined: Thu Jul 03, 2003 6:53 pm
Location: England

Re: Cloud database?

Post 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.
User avatar
NicTheQuick
Addict
Addict
Posts: 1218
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: Cloud database?

Post 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.
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
Post Reply