Code Monkey home page Code Monkey logo

go-mysqldump's People

Contributors

christianruhstaller avatar jamesstewy avatar kesuskim avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

go-mysqldump's Issues

MySQL server version Error

Error dumping: Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'condition' at line 1

Stream to file system instead of keeping data in memory

Hey,

currently the data is rendered after all tables have been retrieved.
This is a viable approach when working with a small database.
However using this library with a database of multiple 10s of GB this is no longer feasible since size of the dump will exceed the memory of the instance you are running the program.

Any plans to extend the functionality of your lib to tackle this issue?

if table name is "order" it will report an error,should add char `` to table

such as sql:
SHOW CREATE TABLE `order` # ok

SHOW CREATE TABLE order # error

here is code below:

func createTableSQL(db *sql.DB, name string) (string, error) {
	// Get table creation SQL
	var table_return sql.NullString
	var table_sql sql.NullString

        // fix it like this,thanks
	err := db.QueryRow("SHOW CREATE TABLE `"+name+"`").Scan(&table_return, &table_sql)

	if err != nil {
		return "", err
	}
	if table_return.String != name {
		return "", errors.New("Returned table is not the same as requested table")
	}

	return table_sql.String, nil
}

License?

What license is the code released under?

I may be blind, but I can't it referenced anywhere.

Is there a way to restore a dump using go?

Hi, is there a way to restore a dump using go?

I tried execute the file but got the next error:

Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COL' at line 7

Also tried spliting the queries with ';' but doesn't work when there's a value with ';' inside.

Using the MySQL CLI or HeidiSQL works well.

I know that works using the cmd/exec package with MySQL CLI. But the target is use go only.

Maybe using a regex? any ideas?

rune dump Replace

source :
table get value is [awk '{print $2}']ใ€‚
dump after:
'awk '{print $2}''

dump.go func createTableValues(db *sql.DB, name string) (string, error) {


for key, value := range data {
if value != nil && value.Valid {
dataStrings[key] = value.String
}
}


}
modify-->
for key, value := range data {
if value != nil && value.Valid {
rune := \'
dataStrings[key] = strings.Replace(value.String, "'", rune, -1)
}
}

Postgresql

hello,
I found this library that dump the mysql database, I was hopeful it was possible to use it for postgres or that there is a solution available,
so far it appears its not so.

So I am guessing is there any plan to make it supported or it looks like a more natural soluion for me to fork and create a postgresql version?

Dump just one table

Is there a way to dump just one table? I only see the entire db, which may be many many gb, and I just want to backup one table before doing an insert.

Feature request: Create batched inserts

It would be great if you could group the insert in batches of thousand items, so that you get some notion of progress when executing the dump with mysql-workbench or other UIs.

Null type is transfer to string type

The type is JSON type and accept NULL type.
When dump with this tool, the data will transfer the NULL to "" type.
When import, it make issue, because "" is wrong type.

Strings not escaped

Hi,

it seems that strings are not escaped properly. e.g. If I open the dump file with Visual Studio Code I see lines like

('2','OPEN_DOOR_CLOSED','If there is a 'Open door' detected and this door is closed now, the message Open Door closed is send.','2018-04-24T16:09:42Z','2018-04-24T16:09:42Z','0','door_closed','0','0','8','0','0')

mysqldump CLI --all-databases equivalent

Does this library include the option of dumping all databases of a MySQL db server? Its CLI equivalent has --all-databases flag which does what I need.

According to the example in the README, dumper works according to its mysql dsn input which requires dbname to be specified. Am I right?

Cannot dump with foreign key constraint

Hello, it seems that InnoDB backup is having some problem. I didn't try MyISAM or anything else storage engine, but with my InnoDB database with Foreign Key constraint cannot be recovered with what I backup with this package. ;(

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.