Kallithea sqlite database to mysql database - mysql

I've Kallithea running on my own server with sqlite database. I would like to move all this data to MySQL database instead. On default Kallithea uses sqlite if not any other database is specified. From Kallithea documentation pdf https://media.readthedocs.org/pdf/kallithea/latest/kallithea.pdf they recommend to use https://github.com/shazow/sqlalchemygrate to migrate data from database to another.
I'm installed sqlalchemygrate using Python pip but when I try to migrate there is parts what I don't understand at all. Help menu doesn't not clearly specify how to use migrate command. At least I don't understand it at all. For example when I try to type
grate migrate "sqlite:./kallithea.db" "mysql://kallithea#localhost/kallithea"
I get error saying
ImportError: No module named sqlite
In help menu it says to use
migrate METADATA ENGINE_FROM ENGINE_TO
Migrate schema or data from one engine to another.
And example how to use it
grate migrate model.meta:metadata \
"mysql://foo:bar#localhost/baz" "sqlite:///:memory:" \
What I don't really understand is what is that metadata it needs? And how to specify sqlite .db file for this. And how to migrate data to new kallithea database in mysql with user kallithea which has all privileges to that database.

Not sure about Kallithea but RhodeCode users had a great success using TAPS (https://github.com/ricardochimal/taps) project to migrate they databases to different format.

ImportError: No module named sqlite
You probably need to install sqlite, and pip install sqlite or similar.
Regarding what metadata it needs, it's referring to metadata in the context of SQLAlchemy: http://docs.sqlalchemy.org/en/latest/core/metadata.html

Related

How to import a mysql db into Azure sql without .net tools

We're running Linux VM's with MySQL on Azure and want to start using Azure SQL, but need to get the data from one into the other, initially.
Is there a way to dump a mysql database and then import that into an Azure sql database?
I'm on a Mac (or can be on Linux), so the .net tools won't help.
I've tried having Azure use the mysql dump. Reads it, but nope.
I've tried selecting the mysql tables from an open connection and drop them on the Azure db, also in an open connection, via Navicat. Nope.
I also tried looking for something in SQLPro for MSSQL. Nope.
Also, I'm willing to edit the mysql dump if there are minor global things to do so that Azure sql will read it.
You can:
1. Install mysql instance on windows based server.
2. Dump all your databases into there using mysql dump.
3. Use all the spectrum of microsoft tools for your goal.

Export Data Dictionary of my database using MySQL Workbench CE?

I have a database on server with around 60 tables and now I want to export Data Dictionary of the database (including table structures)..
I can do that on my local machine which has PHPMyAdmin, however, I am not able to find way to export it on server using Workbench.
Any one who can help?
You may install db_doc.lua, a Lua script plugin for MySQL Workbench that generates data dictionaries, similar to those generated by DBDoc on MySQL Workbench Enterprise.
Download it from:
https://docs.google.com/file/d/0BxXM2ftdUPGeNkM4OGpiYmFxdFk/edit?pli=1
Plugin developer's website
http://tmsanchezdev.blogspot.mx/2013/11/reporte-actualizado-del-modelo-de-la.html
[EDITED]
It seems that the LUA plugin support was discontinued.
So I wrote a plugin in Python to generate data dictionaries.
It is available at: https://github.com/rsn86/MWB-DBDocPy

inspect mySQL database

I have a mySQL database on my Windows PC. I'm pretty sure I've found the relevant files, namely the following:
formula.frm
formula.ibd
db.opt
What is the natural way to inspect, edit, and generally play with the contents of these files?
You do not view the binary database files directly. MySQL is a service that you connect to with a client and then perform SQL commands. You will need a client (such as MySQL Workbench) to work with the server.
MySQL Workbench is the GUI tool that allows you to connect to a MySQL database and perform actions on it including querying and creating/modifying the various parts of the database.
MySQL Workbench intro: http://dev.mysql.com/doc/workbench/en/wb-intro.html
Getting started with MySQL: http://dev.mysql.com/doc/refman/5.6/en/tutorial.html
There is also the command-line utility that is included when you install the server. It will be in the BIN folder of the MySQL install directory.
Command-line client info: http://dev.mysql.com/doc/refman/5.1/en/mysql.html
Use a tool like Mysql Workbench to connect to the DB. You do nothing directly to the files. You connect to the service and use the DB.
William, it sounds like your question is "how do I take mysql binary files and turn them into something usable on my machine?". If that's the case, you'll want to first install MySQL on your machine if you haven't already. Then you might have a look here for how to recreate a database from a .ibd file.

SQLite and MySQL, will the conflict?

I just joined a project where they have been using SQLite. I am more comfortable using MySQL with PHPMyAdmin. If I install phpMyAdmin and work with that will it do any damage?
It is a php project. They have alot of code (sloppy code thats so hard to figure out) for accessing a SQLite db. I dont want to effect that but I want to add some new tables to a new db using mysql and phpmyadmin which i am yet to set up because I'm afraid it will break the code written for the SQLite db
.
Are you talking merely about installing PHPMyAdmin to manage a SQLite database? That won't work, since both use completely different API's to be accessible through PHP.
Or do you wish to swap the SQLite database with MySQL and then use PHPMyAdmin to manage the database? That'll work, as long as the project supports both SQLite and MySQL.
Is it a PHP project? Probably not - mysql_-prefixed methods only work with MySQL as far as I know, and SQLite and MySQL don't listen on the same port by default, do they?
You need to work with what is deployed. If the project is using Sqlite, then use that. Databases are not all equal. If you use something different, your code might not even run on the production databases.
first of all, if you don't want affect, create a branch on github then from work this branch ..
you can also dump all table of this sqlite database to a sql file, then import this file to your phpAdmin, will create the table, since this both manager uses sql language ... just remove some ligne of code that are not compatible with mysql on sql file that you dump data from sqlite dabtase .....
here is the code for dump a sqlite database ....
first select the database on terminal on your project director
sqlite3
./open DATABASENAME
.output YOURSQLFILENAME.sql
.dump
.quit
at this stage you already have your database in a sql file
then use php admin to import this file
if it show some error, just try to remove somecode that aren't compatible with mysql on sqlfile.

How to import a SQL Server .bak file into MySQL?

The title is self explanatory. Is there a way of directly doing such kind of importing?
The .BAK files from SQL server are in Microsoft Tape Format (MTF) ref: http://www.fpns.net/willy/msbackup.htm
The bak file will probably contain the LDF and MDF files that SQL server uses to store the database.
You will need to use SQL server to extract these. SQL Server Express is free and will do the job.
So, install SQL Server Express edition, and open the SQL Server Powershell. There execute sqlcmd -S <COMPUTERNAME>\SQLExpress (whilst logged in as administrator)
then issue the following command.
restore filelistonly from disk='c:\temp\mydbName-2009-09-29-v10.bak';
GO
This will list the contents of the backup - what you need is the first fields that tell you the logical names - one will be the actual database and the other the log file.
RESTORE DATABASE mydbName FROM disk='c:\temp\mydbName-2009-09-29-v10.bak'
WITH
MOVE 'mydbName' TO 'c:\temp\mydbName_data.mdf',
MOVE 'mydbName_log' TO 'c:\temp\mydbName_data.ldf';
GO
At this point you have extracted the database - then install Microsoft's "Sql Web Data Administrator". together with this export tool and you will have an SQL script that contains the database.
MySql have an application to import db from microsoft sql.
Steps:
Open MySql Workbench
Click on "Database Migration" (if it do not appear you have to install it from MySql update)
Follow the Migration Task List using the simple Wizard.
I did not manage to find a way to do it directly.
Instead I imported the bak file into SQL Server 2008 Express, and then used MySQL Migration Toolkit.
Worked like a charm!
In this problem, the answer is not updated in a timely. So it's happy to say that in 2020 Migrating to MsSQL into MySQL is that much easy. An online converter like RebaseData will do your job with one click. You can just upload your .bak file which is from MsSQL and convert it into .sql format which is readable to MySQL.
Additional note: This can not only convert your .bak files but also this site is for all types of Database migrations that you want.
Although my MySQL background is limited, I don't think you have much luck doing that. However, you should be able to migrate over all of your data by restoring the db to a MSSQL server, then creating a SSIS or DTS package to send your tables and data to the MySQL server.
hope this helps
I highly doubt it. You might want to use DTS/SSIS to do this as Levi says. One think that you might want to do is start the process without actually importing the data. Just do enough to get the basic table structures together. Then you are going to want to change around the resulting table structure, because whatever structure tat will likely be created will be shaky at best.
You might also have to take this a step further and create a staging area that takes in all the data first n a string (varchar) form. Then you can create a script that does validation and conversion to get it into the "real" database, because the two databases don't always work well together, especially when dealing with dates.
The method I used included part of Richard Harrison's method:
So, install SQL Server 2008 Express
edition,
This requires the download of the Web Platform Installer "wpilauncher_n.exe"
Once you have this installed click on the database selection ( you are also required to download Frameworks and Runtimes)
After instalation go to the windows command prompt and:
use sqlcmd -S \SQLExpress (whilst
logged in as administrator)
then issue the following command.
restore filelistonly from
disk='c:\temp\mydbName-2009-09-29-v10.bak';
GO This will list the contents of the
backup - what you need is the first
fields that tell you the logical names
- one will be the actual database and the other the log file.
RESTORE DATABASE mydbName FROM
disk='c:\temp\mydbName-2009-09-29-v10.bak' WITH MOVE 'mydbName' TO
'c:\temp\mydbName_data.mdf', MOVE
'mydbName_log' TO
'c:\temp\mydbName_data.ldf'; GO
I fired up Web Platform Installer and from the what's new tab I installed SQL Server Management Studio and browsed the db to make sure the data was there...
At that point i tried the tool included with MSSQL "SQL Import and Export Wizard" but the result of the csv dump only included the column names...
So instead I just exported results of queries like "select * from users" from the SQL Server Management Studio
SQL Server databases are very Microsoft proprietary. Two options I can think of are:
Dump the database in CSV, XML or similar format that you'd then load into MySQL.
Setup ODBC connection to MySQL and then using DTS transport the data. As Charles Graham has suggested, you may need to build the tables before doing this. But that's as easy as a cut and paste from SQL Enterprise Manager windows to the corresponding MySQL window.
For those attempting Richard's solution above, here are some additional information that might help navigate common errors:
1) When running restore filelistonly you may get Operating system error 5(Access is denied). If that's the case, open SQL Server Configuration Manager and change the login for SQLEXPRESS to a user that has local write privileges.
2) #"This will list the contents of the backup - what you need is the first fields that tell you the logical names" - if your file lists more than two headers you will need to also account for what to do with those files in the RESTORE DATABASE command. If you don't indicate what to do with files beyond the database and the log, the system will apparently try to use the attributes listed in the .bak file. Restoring a file from someone else's environment will produce a 'The path has invalid attributes. It needs to be a directory' (as the path in question doesn't exist on your machine).
Simply providing a MOVE statement resolves this problem.
In my case there was a third FTData type file. The MOVE command I added:
MOVE 'mydbName_log' TO 'c:\temp\mydbName_data.ldf',
MOVE 'sysft_...' TO 'c:\temp\other';
in my case I actually had to make a new directory for the third file. Initially I tried to send it to the same folder as the .mdf file but that produced a 'failed to initialize correctly' error on the third FTData file when I executed the restore.
The .bak file from SQL Server is specific to that database dialect, and not compatible with MySQL.
Try using etlalchemy to migrate your SQL Server database into MySQL. It is an open-sourced tool that I created to facilitate easy migrations between different RDBMS's.
Quick installation and examples are provided here on the github page, and a more detailed explanation of the project's origins can be found here.