GithubHelp home page GithubHelp logo

isabella232 / pg2mysql-1 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dolthub/pg2mysql

0.0 0.0 0.0 119 KB

Script to convert Postgres dump files to MySQL dump files

License: Apache License 2.0

Perl 28.77% Shell 71.23%

pg2mysql-1's Introduction

pg2mysql

pg2mysql transforms a pgdump file on STDIN into a MySQL dump file on STDOUT. Dump format must be INSERT statements, not binary or COPY statements (ie. pg_dump --insert <dbname>).

Usage:

./pg2mysql.pl < file.pgdump > mysql.sql
./pg2mysql.pl --skip table1 --skip table2 --insert_ignore < file.pgdump > mysql.sql 2>warnings.txt

It handles:

  • CREATE TABLE statements, types converted to MySQL equivalents
  • INSERT INTO statements, some values (like timestamp strings) massaged to work with MySQL
  • CREATE INDEX statements
  • ALTER TABLE statements (for foreign keys, other constraints)
  • Sequence nextval column defaults translated to auto_increment
  • With --insert_ignore, uses INSERT IGNORE statements to be more lenient with non-confirming values (at the cost of import accuracy)

All other statement types other than the ones above are ignored, and echoed as SQL comments to STDERR. If you want them in your final script, redirect STDERR to STDOUT with 2 >&1 when running the script.

Known issues

The script has a lot of limitations and there are surely bugs. If you find some, file an issue to tell us. But these are the things we know about:

  • Only tables supported. Other schema entities like triggers, views, stored procedures are not created
  • Some types badly / not supported
  • Will convert a character varying type to longtext if no length is specified, which means MySQL won't be able to make it a key

Requirements

You must have Perl installed at /usr/bin/perl to run the script directly.

Credits

pg2mysql is heavily inspired and informed by this project of the same name: https://github.com/ChrisLundquist/pg2mysql

Which in turn was adapated from this web form: http://www.lightbox.ca/pg2mysql.php

pg2mysql-1's People

Contributors

timsehn avatar zachmu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.