Load the entire Database from the webserver to IOS native app - objective-c

I am developing a app where i need to keep the replica of entire database from the web server to the IOS native sq-lite database, How can i keep updated version of db or import at loading of the app in one go, What should be my approach to go with this problem, Any help would be really appreciated,
Thanks
Deepesh

Looks like this is a popular problem. According to this answer,
Not every DB schema can be converted. MySQL is more complex and feature-rich than SQLite. However, if your schema is simple enough, you could dump it into an SQL file and try to import it / load it into an SQLite DB.
To do this, you can either use this mysql2sqlite.sh script like so
./mysql2sqlite.sh myDbase | sqlite3 database.sqlite
or use this answer and simply do
mysqldump database > database.sql
sqlite3 database < database.sql

Related

Creating a local SQL database file?

Please note:
I am a game programmer, so backend development isn't my forte. There are times, however, where I work with our database at my job. Please don't shoot me if my question is ridiculous.
Is there a way to create a local mySQL file and access it through PHP or C#?
I know you can make a local webpage on your machine (pretty much for testing purposes) and access multiple locally created files.
I assume that something similar would work with mySQL. (Are the login credentials also stored within the file?) I remember seeing a few online tutorials where it offered a download for both PHP and the database file, but I can't seem to find them now.
I've searched for this, but all the relevant results involved downloading mySQL and hosting a server which is a bit more than I wanted to do.
So if its possible to create a local mySQL, how do you do so?
The tools I intend on using while doing this:
PHP/JQUERY/HTML and C#
For MyISAM tables, inside the MySQL data directory there is one directory per database which contains several (usually three) files per table. For InnoDB tables, they are all contained in several files directly inside the data directory.
The location of the MySQL data directory is usually set in my.cnf using the datadir parameter.
The login credentials are stored in a special database called "mysql" which is in that data directory like any other database.
However, you have to install and run MySQL to access those files. You cannot access them with PHP or any other client API alone. If you want to do such a thing, better use SQLite.
MySQL is a database engine, u need to install that before you can use it. Unlike SQLite which stores it's database in files. Maybe that is something more of your liking. And I know there are library that supports SQLite for PHP, not sure about the rest.
SQLite you don't need to install anything.
MySQL can be used an an embedded database, but you will need to contact them in order to purchase a copy of it.

MySQL getting unknown characters in data between Linux & Windows hosted databases

I am lost on this. I have a web site that I work on offline, then I upload to live server, import MySQL database to live server, and make live in general. Problem is that when I export database from LIVE server and import back into LOCAL server, I get unknown characters in my XHTML output, the black diamond with the white question mark in the middle, you know the one.
The command I used to export my database from LOCAL MySQL installation is as follows:
mysqldump --verbose -hlocalhost -uxxx -pxxx --databases xxx --add-drop-table --default-character-set UTF8 > somedir/xxx.sql
Then, when importing that data to the LIVE database I used a simple command as follows:
mysql -hlocalhost -uxxx -pxxx somedatabase < xxx.sql
Great, all is well, data is imported and there are NO unknown characters on site. However, when I do the same in reverse (dump on live server using same command as in windows, import in windows using same mysql command) that is when all the unknown characters appear.
Is it a collation issue? Am I using the incorrect --default-character-set ?
I have never had this happen before, and I would love some feedback or a nudge in the right direction.
UPDATE: I have completely dropped my local one, exported the ENTIRE live db and imported. Still the same error :/ This is driving me mad!
Many thanks,
Simon
Try on both sides:
SET names UTF-8
Probably the defaults differ.
I suspect your live site has a different database schema, could it be latin1?

setup local informix db as in server

currently i'm working with informix db server which is not in local, where can't connect from outside office or virtual lan, so there is any tools so i can copy all table and work locally,
thanks in advance
You can export database to text using dbexport and import it locally using dbimport. There are other way of migrating database, but for small databases it should work. The data is in text so it may be easy to change something (for example data format), or even use such export to import data to other database. Have a look at: http://publib.boulder.ibm.com/infocenter/idshelp/v10/index.jsp?topic=/com.ibm.mig.doc/mig138.htm

querying database in android

I am building an android app and I have an SQL database stored on a server. I need to either pull the database into android or query the database and have it return information from the tables. I have searched all over the internet but I haven't found anything that explains how to connect to the server from android. How can I do this?
You can't query database in a server from android directly. You have to write PHP scripts to query database from server. You have to keep the php scripts in a web server. And from android application you have to get the data from the php page.
I don't think there is a reasonably simple way to 'pull' the database or connect to it using some soft of ODBC connection. And I don't think it would be wise to use it even if possible.
I believe the best way to solve your problem would be to implement some sort of REST API interface to your database and fetch data as needed.
actually, despite gypsicoder's answer and several "how to"s on the internet, there is a way to connect/query an SQL database from android
you just have to download the corresponding JDCB. for mysql: http://dev.mysql.com/usingmysql/java/
then you just use the java.sql interfaces/classes to do stuff (mysql has a reference manual at above link)

Importing data to MySQL from MS SQL

I want to import data from MS SQL Server, run it through some sort of regexp to filter out stuff, and import it into MySQL. I then, for each query, wish to display a relevant image from a third database. What would be the easiest way to do this, importing and linking wise?
Thank you.
Clarification: It is a php application to filter data from another database, and then for each record show an associated image from a 3rd database. It is from scratch...
You can try the MySQL Migration Toolkit.
http://dev.mysql.com/downloads/gui-tools/5.0.html
Now archived at http://downloads.mysql.com/archives.php?p=mysql-migration-toolkit
use SQL Management Studio (or Enterprise Manager depending on version) with the SQL Server import wizerd to get it into MS SQL.
From there you can export it to Mysql using the MySQL connector drivers.
As for as displaying an image from a third database, that is completely up to the code you have written in your application.
I would use the Microsoft SQL Server Data Publishing Wizard (free). You can use it to script your entire database (including insert statements.) You'll have to edit this script a little bit probably to get it to run in MySQL. Now you just have a regex problem. You can try:
Manipulating the data in MS SQL via a query, or from code (using regex) the transfer.
Running your regexes on the script file itself, maybe try some macros, find and replace, etc.
Manipulating the data in MySQL via a query, or from code (using regex) after the transfer.