Web database example project

While doing research into web edition I wanted to set up a simple app that will connect to a local database and make modifications. From looking around, I’ve seen that I should be worried about some issues with the session global variables, as well as some other finicky elements in WE when working with databases.

Is there an example WE project that includes any database code to look at to see where it is best practice to store information about the database/session/etc and how best to access and modify database information specifically from a Web App? I have plenty of experience in databases on desktop apps, but it looks like things are different for WE apps with databases.

Thanks!

Have you tried the example projects Sample Applications> Eddies Electronics> Web? That’s the same project that xojo uses in their demo website app.

Yes, the Eddie’s Electronics web example is a good place to start. I also briefly touch on DB access in the SQLite webinar from last week.

http://documentation.xojo.com/index.php/Videos

The short of it is that you should have a separate DB connection for each user session. If using SQLite, you likely also want to set MultiUser = True to enable write-ahead logging for fast disk writes. Otherwise, DB access is not really all that different between a web app and a desktop app.

I have a web app that has been deployed for ever a year. I’m genuinely curious what these finicky issues are that you came across?

Thanks, that example is perfect. I was only looking within the Examples > Web Folder, and Examples > Databases folder.

People have had other posts about issues using the pseudo global session method, sessions and databases getting mixed up, and issues related to using SQlite with multiple users.

I haven’t encountered any of these, that was just what I’ve found while looking into Xojo web apps on the forums here.

I’d like to track down that conversation. I have had a couple of users say that dates they inputted weren’t correct. The fact that it’s just dates and is so rare made me think user error. But I’m open to investigating other possibilities.

This was one of the discussions:
https://forum.xojo.com/4881-sessions-and-modules

[quote=45733:@Paul Lefebvre]Yes, the Eddie’s Electronics web example is a good place to start. I also briefly touch on DB access in the SQLite webinar from last week.

http://documentation.xojo.com/index.php/Videos

The short of it is that you should have a separate DB connection for each user session. If using SQLite, you likely also want to set MultiUser = True to enable write-ahead logging for fast disk writes. Otherwise, DB access is not really all that different between a web app and a desktop app.[/quote]

Thanks for the info & help. I’m assuming there isn’t anything in the examples for connecting to a local MySQL server that’s already on the server? I would be integrating a Xojo Web App with some existing PHP pages that pull data from a MySQL database on the same server. Just trying to wrap my mind around WE and see if that’s the right tool for this job.

If MySQL is on the server, then you would connect using localhost or 127.0.0.1 in the web app when it runs on the server. You would still create a new connection for each user session.

Yep thanks. In the process of getting a sample app set up and connecting to the database but I run into “unable to launch application on port xxxxx” errors about 80% of the time I upload a new build. I’ve checked file permissions and have set an app identifier. I guess that’s a separate issue. :slight_smile:

Make sure you kill any running processes for the web app before you deploy a new one. The old process could be locking the port.

So very simple apps that I build will upload and run fine, but now that I’ve added some code for the MySQL server, it’s including the MySQLCommunityPlugin.so along with some other libraries. Should I be worried about issues between 32/64 bit if I’m on a 64 bit server?

As Xojo apps are 32-bit only, you’ll need to install appropriate 32-bit compatibility libraries for your Linux server for Xojo web apps to run. I suspect MySQL on the server would also need to have a 32-bit driver available.

From the managed hosting provider:

[quote]Because of the way that our system is set up installing 32bit packages will cause issues with the server and also with the automated patching.
If you really want to install them we will need to install them on your own because we are not able to provide support for something like this.
Also ia32 is not available in our repositories.[/quote]

Does this mean WE apps are basically a no-go on this specific server?

I may be missing something, but since you have any WE app running, no matter how simple, doesn’t that mean you have enough 32-bit compatibility installed? I thought it was go/no-go. Any additional complexity, such as the MySQLCommunityPlugin.so, you’re supplying in your Libs folder yourself.

It shouldn’t, since the communication is TCP.

Right that’s why I am a bit confused. I’m still getting some of the apps to run properly (very, very basic ones), but I haven’t gotten anything to run with the MySQLCommunityPlugin included. I was under the impression that it wouldn’t run at all since it’s a 64bit server.

[quote=45763:@Tom I.]This was one of the discussions:
https://forum.xojo.com/4881-sessions-and-modules[/quote]

I recall skimming that now. I found the whole issue confusing.

I’m glad someone found the EEWEb example useful. It doesn’t really make sense to me. It appears that they create a new database for each session. That seems like an odd hack. Why isn’t it being done with a database in the session object? Is that the issue people were saying is problematic?

Another thought, would the “Unable to launch application ‘xxxxx’ on port xxxxx” error message even be an indication of a 32/64 bit problem? Would it even get to the point of that error message if it wasn’t capable of running the application due to that?