Synchronizing SQLite and MySql together - mysql

I am trying to synchronize 2 different type of database together. Here is a better explanation of what I am trying to do:
I have the MySQL database on a server with the main database. I have an application installed on multiple computers.
I need the main database to be updated with the modification inside the computers and I need the computer version to get the updates from the main database.
I have seen the replication option in MySQL but it's not exactly what I want to do. I have seen other stuff like REPLACE INTO but I still don't see a clear solution.
I'm not asking for a full solution but maybe a good pseudocode or some cool functionality so I can try to implement it. This will be used on my end of school project.
I obviously have a timestamps on each row so I can detect changes.

This is how I would do this if I had an app that will run in different SQL environments.
It will be cleaner if you do the communication between yourApp & DB through some php class. This class instance will be created based on user's SQL version. Then, it is for your code in the class to decide how to connect to your DB.

Related

connecting already existing database in a local environment

I have an access database that connects to a vb6 application and this whole thing is connected between two computers via a shared network one running win 8 and other a win 7, and there is no internet involved in any sorta way nor should it be that is a requirement in fact
sorry I advance I have tried researching on the net but there is really short time and a lot of confusing material online
I am creating a WPF app connected to MySQL DB
now I have copied the access file and imported the contents of the DB in MySQL
things are a real mess in the imported DB so I am fixing it
what I am confused is how I am going to make it work there
do I go and install MySQL and do the whole process manually there, repeating all the steps and changes
is made
make a document that contains the code/script for all the changes I have made and run the data through
it, and is there even a way to implement that as a whole in a singular go
connect both databases together, i don't even know if this is possible
yes, in place of a simple "file share" of the Access file, you now are going to run some kind of SQL server system. In this case MySQL. But it could be PostgreSQL or any kind of "server" database.
That instance of "sql server" thus has to be setup, installed and you ensure that the "box" running that instance of MySQL also allows external connections (often by default the given computer firewall settings prevent this).
At that point, 2 or 10 different computers on that same network can now simply connect to the SQL server. The code of course is going to be VERY simular. You almost for sure used the oleDB provider for use with Access. However, you can use the ODBC provider, or even use the provider from MySQL. Those providers thus means you change the connect object, datareader object etc. However the "base" .net types such as row, or datatable, or dataset can remain as before (so you only change the provider). If you have a lot of code based on oleDB, then you could well consider to contine to use that oleDB provider code in .net, and thus you change the connection strings to now point to MySQL.
If you don't have a lot of code, then for sure do adopt the mySQL provider for .net. But as noted the least amount of changes would be to continue to use a oleDB provider for mysql, and that would suggest the least amount of code to be changed.
As for the msaccess data migration? Well, it not clear what tools and how you doing that now. But, once you transfer the data to the MySQL server (assuming you installed + setup my sql to run on one computer). The it is a simple matter to point your .net connection(s) in your code to Now MySQL as opposed to Acess. As a result, most if not all of your code logic for working with the tables can remain as before - but as noted you have to swap out the provider parts in .net
Now, if your REALLY lucky and the .net code used the ODBC provider? Then all you have to do is change your connection strings. And of course "some" SQL syntax in your code may have to be tweaked, as like Oracle, MS SQL server, postgreSQL, and MySQL?
Well, they all have some features and syntax that is different - this is especially in regards to date/time calculations, datediff() etc. But the general sql you have/had in your .net code should continue to run mostly un-changed against MySQL data tables.
As for how to migrate the data? I think that a really good tool is of course to use MS-Access. What you do is get MySQL up and running. Then use ms-access to open that database. You then add linked tables from MS-access to the MySQL tables.
At that point, you can now run append queries from Access to move/send the data to MySQL. It really depends on how many tables, and how many related tables are in that database. The more complex and the greater number of related tables in Access then the more the challenge to move such data up to MySQL.
Transferring Excel or a small or even big table is a breeze. (again, use MS Access and link to the tables on the sql server). However, where things can become messy is that if you have say 25 tables, and they are all related, many have cascade delete and say enforced parent to child relationships. So the more tables, and especially a larger number of related data tables, then the more work such a data migration task will become.
I think MS Access is a really good tool, since if you setup a connection to MySQL, then you can execute a transferDatabase commend in Access to send up one table to MySQL, and even all the columns and data types for those columns will be automatic created for you. So not only can Access transfer the data, but MORE valuable is it has the abilty to create the target tables on MySQL for you - and that will save you large amounts of time to build + setup the tables on MySQL.

Compare database differences and get SQL output

I need ability to compare two similar databases. One will be slightly newer than the other and have changes to the structure of the database as well as possibly the content within it.
So far I have tried using liquibase but it doesn't seem to be comparing properly.
I have also tried the MySQL Diff Perl module which works but doesn't consider content.
Main Question:
Does anyone know any solutions that will give back SQL for both structural and content differences and generate a SQL script?
A bit more info:
The intended use for this is when making updates and installing MODs to phpBB so that the forum can be included in the build process along with the rest of our website. Which has a 4 tier process (local, development, staging, production).
When installing the phpBB updates and MODs I will make a dump of the current production database and lock the site so no new data can be added whilst I make changes. That way databases shouldn't come out of sync.
When installing MODs and updates sometimes the database structure changes and also the data within tables, especially when adding things requiring extra permissions etc.
The solution I use therefore will be used to compare the local database with the upgraded changes to the production database, providing me with a script I can run on each tier in the build process, rather than manually installing the update/MOD on each.
You can use SQLyog Database synchronization tool to sync two databases,either one-way or two-way. By far this is the best data comparison tool for MySQL GUI. And, Schema sync for schema comparisons between two databases.
Both tools can generate SQL scripts.
I've actually found a way to do it via Navicat for MySQL using the Tools > Structure Syncronization option.
This will give SQL statements for differences in structure between the two databases.
Then do do the data differences you can use Data Syncornization.
I've managed to copy out the SQL script for differences in structure. However the data syncronization seems to be more of an internal Navicat thing. I'm sure there's a way that the queries could be extracted though.
Please note I'm using a license version so not sure if its available in the free to use one.

creating a basic database

Right now, in my internship, I'm assigned to create a system that holds employee information such as personal info, education, salary, etc.
All these stuff is kept in a few spreadsheets right now. I need a basic program, but I feel like I should be using MySQL or another database solution to hold the data. I used MySQL before, but it was a PHP/MySQL assignment which I used Wampserver to create the whole system.
Edit: The system will be used by a few computers across the network. When someone makes a change to the system, it will become visible to other computers aswell. (obviously) (Before the edit, I thought that it's gonna be used by a single computer.)
I'm confused right now. Should I create a PHP/MySQL webpage with wampserver (or similar) to hold the information, or not?
Would it be easier or better to combine MySQL with some other programming language (such as Java/C++) and build a GUI? (I doubt it)
Should I come up with a different solution? Without database usage?
Database usage would be the best option. In the end it will come down to what you are more comfortable using, Java/C++ or php, for what you want to do either can work, but remember the database will need to be live at all times and using wamp server wont cut it. You need to learn how to tun a mysql server without wamp, which is easy(Google is awesome). And personally I would have used Java because Java is also easy to link with mysql, just google it a bit, and java doesn't need to run on a server so no wamp needed as you would have needed for php.
EDIT:
Ok if I understand you correctly what you want to do is the following:
1. Identify a pc to be used as a server and assign it a static IP.
2. This must also be the pc that is turned on first every day and turned of last.
3. Create a front end client application that connects to your sql server that you will be running on the server machine.
Now I am assuming this network is rather small, so you wont need a specific computer to just act as server. The server can also be one of the client machines.
The best approach would be to create a mysql server and make sure the firewall is not blocking your sql server. Then create a client application that can access the database over the network using Java, I find this easier than creating a php server for the users because of port forwarding for an apache server is time consuming, I did it once and never again. Java will be easiest to make the application work over the network. Use Netbeans for the development, it's an awesome IDE and it makes life easier when setting up the database connection.
If you have anymore questions please ask in comment, and I will elaborate, since this might be a bit vague lol.
Of course you should use a database for this type of work. That is the best way to organize, search, sort and filter your data without having to reinvent the wheel.
As to the other questions, the choice of language and environment is up to you to decide after evaluating the needs of your application.
Your solution should use a database to store the data and an front-end application to manage the data.
The database and front-end should be seen as two separate layers. In other words create the database using whatever database your are familiar with eg: MySQL and likewise create the front-end using whatever technology youre familiar with eg: PHP.
Personally for this type of requirement i would typically use MySQL / SQLExpress and ASP.Net / MVC3 front-end.
Hope this is helpful.

How to collaborate on mysql schema?

I'm working with another dev and together we're building out a MySQL database. We've each got our own local instances of MySQL 5.1 on our dev machines. We've not yet been able to identify a way for us to be able to make a local schema change (eg: add a field and some values for that field) and then export some kind of script or diff file that the other can import in. I've looked into Toad and Navicat's synchronization features but they seem oriented towards synchronizing between two instances, not an instance and an intermediate file. We thought MySQL Workbench would be great but this but the synchronization feature just seems plain broken. Any other ideas? How do you collaborate with others on the schema?
First of all put your final SQL schema into version control. So you'll always have a version of it with all changes. It can be a plain SQL file. Every developer in the team can use it as starting point to created his copy database. All changes must be applied to it. This will help you to find conflicts faster.
Also I used such file to create a test database to run unit-tests after each submit. So we were always sure that production code is working.
Then you can use any migration tool to move changed between developers. Here is similar question about this:
Mechanisms for tracking DB schema changes
If you're using PHP then look at Doctrine migrations.

Update MySQL database from SQL Server in different domain

I am SQL Server developer and the current assignment is little different than what I have done in past. I found Stack Overflow very promising for my problem. I am working on the SQL Server 2005 database for the internal application for my client and the client also got the public facing web application with MySQL database. I do not have any details about this web application, but I got the assignment to update the MySQL database (on public domain) from the SQL Server database (internal domain) on daily basis as auto process. How can I achieve this through the SQL Server?
You might want to try Pentaho Data integrator.
http://wiki.pentaho.com/display/EAI/Latest+Pentaho+Data+Integration+%28aka+Kettle%29+Documentation
The product would allow you to speak to both data technologies. (MSSQL+MySQL) You will find the product similar to DTS. You may be able to construct your solution will little to no code.
SSIS will do this just fine. The hard part is determining how you want to transform the data from one structure to the other (I assume they are not exactly alike in terms of table design.)
But basically you create a dataflow task, connect to the SQL Server for the source data and use a query to define what data you are going to copy, then you do any transformations needed to make the data fit into the MySQL structure and connect to a MySQL destination.
Repeat this process for mulitple data sets you want to send to differnt places.
Once the SSIS pacakge is done, set up configurations so that you can run the package on the production server (you will want to test development to development of course!) then schedule the package to run at an appropriate time.
Depending on how different the two databases are and how much data you need to move, this can be a relatively simple process or very complicated.