This is not a codefix question but please help me where possible.
I am developing an application which needs to store information in a database. This information needs to be stored off-device for security reasons (patient data).
I have explored using PHP as a bridge to the external MySQL database hosted locally via WAMP, however I have recently been informed of servlets and also of SQLite.
As I am learning these technologies under a limited time frame I need to know which to invest my time into to get the job done as easily as possible. I have no experience with any query language but I did get a simple login screen to work on Android using PHP and MySQL on WAMP using HTTP post/fetch within android.
Also, is it possible to store the information in SQLite within android and write that data to a server, which can then load the SQLite database again on re-launch?
Many thanks for your time!
From our expericence these kind of services need to work offline if possible. Both 3g and especially wifi has been unreliable in several occasions.
You do good if you save the data locally in e.g. sqlite database but be warned the data can get wiped on OS update or software update.
Also try to write your changes/additions in batches and servr updater can send all the batches that are not yet on the server. this way it's more reliable if you miss updates.
These kind of interfaces to another systems take a lot of time in testing. Consider getting a new timeframe in advance.
You will find more about Android connection to MySQL here
Related
Ok, so I'm in the starting stage of a new project where I have an apache web server with PHP included and a MySQL database.
The main focus aim of this project is to show data in this MySQL database as real time on the web page. The problem I have is I am not allowed to install any new software on the server, so I cannot use nodejs or socket.io
I've been looking at the PHP long polling possibility, but I'm curious if anyone out there has managed to pull off something similar without grinding their server to a halt due to too many threads being used.
I've heard about comet, but not sure how that would work as from reading it seems to just look at flat files, not databases.
Thanks for any help.
This is easily achievable with jquery and php, create a php file and echo json encoded data in return. Usage can be found here: jquery post
I have an application that gets data from a SQL Server database using a PHP Script stored in an online server.
I get the data on my iOS app with NSURLConnection, I connect to the script and the script executes the queries on the server.
My question is, can I store this script on the iPhone or iPad and forget the online server?
Also, can I execute SQL Server queries without PHP Scripts and POST methods?
If your database is static(no update), then you can use iOS's native CoreData to manage the database locally and you dont need internet connection at all.
If your database needs to be updated after you release your application, then you will need a server.
In either case the programming language on iOS will be Objective C and C++ (instead of Python).
I was searching a lot of time for some library to do that I want. I found this library:
https://github.com/martinrybak/SQLClient
Main blog of the proyect:
http://objcsharp.wordpress.com/2013/10/15/an-open-source-sql-server-library-for-ios/
If you know another Libraries you can post in this thread for help the people with the same problem.
Regards.
I have a very simple web page in PHP that uses a MySQL database to randomly feed a simple quiz that goes on forever as long as the user wants to keep answering questions.
I want to move this to my Android to be able to use it offline. I used jQuery Mobile to adapt the layouts to the smartphone. So now I want to move the database to a local database and remove all the need to an internet connection. I have absolutely no experience on Android development so if anyone can help me with a few questions, I'd appreciate it:
How can I store my existing database in the smartphone?
The only actions that the app performs on the database are selects. The information on the database will grow with time (not much, I just want to be able to add more records with time). Is there any tool I can use to manage the local database and add the information as I need (as I do now with PhpMyAdmin)?
The web page exists online right now, will I be able to run it locally as it is? (aka, PHP page with css and js files)
Thanks in advance.
1) Android databases are done in SQLite. I'm unsure exactly what the syntax difference between mySQL and SQLite is, but if a straight dump/import doesn't work, you could export to csv/import that way. For info on getting an external database packaged with an app, check Using your own SQLite database with Android applications. It's a very helpful guide to getting it set up.
2) I use a Firefox add-on, SQLiteManager. I hate doing it, as it's the only reason I have Firefox installed any more, but on *nix it's the best option I've found. It's either that, command line, or SQLiteMan, which I found feature-lacking. On other platforms, I can't comment.
3) I don't know if PHP has a good library for SQLite. If so, you'll most likely need to do some modification to work with that instead of mySQL. If you can get that running smoothly, you should be able to drop it into a webview. The other option is to redo it in Java.
Good luck!
I have a web applications that stores data in a MySQL database on-line. It also retrieves data using PHP code, performs calculations on the server and sends the result back to the user.
Data it's quite simple: names, descriptions, prices, VAT, hourly charges that are read from the database and manipulated on the server side.
Often client work in environments where the internet connection is poor or not available. In this case I would like the client to be able to work offline: enter new names, descriptions, prices and use the last VAT to perform calculations. Then synchronise all data as soon as a connection is available.
Now the problem is that I do not know what is the best way or technologies for achieving this. Don't worry, I am not asking to write code for me. Can you just explain to me what is the correct way to build such a system?
Is there a simple way to use my online MySQL and PHP code locally?
Should I save the data I need in a local file, rebuild the calculation in JavaScript, perform them locally and then synchronise the data if database is available.
Should I use two MySQL database, one local and one online and do a synchronisation between the two when data is available? If yes which technology (language) shall I use to perform this operation?
If possible, I would like an answer from PHP coders that worked on a similar project in the past and can give me detailed information on framework structure and technology to use. please remember that I am new to this way of writing application and I would appreciate if you can spare few minutes and explain everything to me like if I am six year old or stupid (which I am!)
I really appreciate any help and suggestion.
Ciao,
Donato
There are essentially 3 ways to go:
Version 1: "Old school": PHP-Gtk+ and bcompiler
first, if you not have done so already, you need to separate your business logic from your presentation layer (HTML, templating engines, ...) and database layer
then adapt your database layer, so that it can live with an alternative DB (local SQlite comes to mind) and perform synchronisation when online again
Finally use PHP-Gtk+ to create a new UI and pack all this with bcompiler
Version 2: "Standard": Take your server with you
Look at Server2Go, WampOnCD and friends to create a "double clickable webserver" (Start at Z-WAMP)
You still need to adapt your DB layer as in Version 1
Version 3: "Web 2.x": Move application from server to browser
Move your application logic from the server side (PHP) to the client side (JS)
Make your server part (PHP) only a data access or sync layer
Use the HTML5 offline features to replace your data access with local data if you are offline and to resync if online
Which one is best?
This depends on what you have and what you want. If most of your business logic is in PHP, then moving it into the browser might be prohibitingly expensive - be aware, that this also generates a whole new class of security nightmaares. I personally do not recommend porting this way, but I do recommend it for new apps, if the backing DB is not too big.
If you chose to keep your PHP business logic, then the desicion between 1 and 2 is often a quiestion of how much UI does your app have - if it's only a few CRUD forms, 1. might be a good idea - it is definitly the most portable (in the sense of taking it with you). If not, go with 2.
I have worked with similar system for ships. Internet is expensive in the middle of the ocean so they have local web servers installed with database synchronization via e-mail.
We also have created simple .exe packages so people with no experience can install the system or update system...
There have been many questions along these lines but I'm struggling to apply them to my scenario. Any help would be be greatly appreciated!
We currently have a functioning mySQL database hosted on a website, data is entered from a website and via PHP it is put into the database.
At the same time we want to now create a python application that works offline. It should carry out all the same functions as the web version and run totally locally, this means it needs a copy of the entire database to run locally and when changes are made to such local database they are synced next time there is an internet connection available.
First off I have no idea what the best method would be to run such a database offline. I was considering just setting up a localhost, however this needs to be distributable to many machines. Hence setting up a localhost via an installer of some sort may be impractical no?
Secondly synchronization? Not a clue on how to go about this!
Any help would be very very very appreciated.
Thank you!
For binding Python to MySql you could use HTSQL:
http://htsql.org
You can then also query your MySQL DB via http requests, either from AJAX calls or server-side e.g. cURL (and of course still have the option of writing standard SQL queries).
There is a JQuery plugin called HTRAF that handles the client side AJAX calls to the HTSQL server.
The HTSQL server runs on localhost as well.
What OS would you be using?
How high-performance does your local application need to be? Also, how reliable is the locally available internet connection? If you don't need extremely high performance, why not just leave the data in the remote MySQL server?
If you're sure you need access to local data I'd look at MySQL's built-in replication for synchronization. It's really simple to setup/use and you could use it to maintain a local read-only copy of the remote database for quick data access. You'd simply build into your application the ability to perform write queries on the remote server and do read queries against the local DB. The lag time between the two servers is generally very low ... like on the order of milliseconds ... but you do still have to contend with network congestion preventing a local slave database from being perfectly in-sync with the master instantaneously.
As for the python side of things, google mysql-python because you'll need a python mysql binding to work with a MySQL database. Finally, I'd highly recommend SQLalchemy as an ORM with python because it'll make your life a heck of a lot easier.
I would say an ideal solution, however, would be to set up a remote REST API web service and use that in place of directly accessing the database. Of course, you may not have the in-house capabilities, the time or the inclination to do that ... which is also okay :)
Are you planning to run mysql on your local python offline apps ? I would suggest something like sqlite. As for keeping things in sync, it also depends on the type of data that needs to be synchronized. One question that needs to be answered:
Are the data generated by these python apps something that is opague ? If yes (i.e. it doesn't have any relations to other entities), then you can queue the data locally and push it up to the centrally hosted website.