AI prompts
base on A zero-dependency, high-performance, concurrent mysqldump tool implemented in golang. golang 中实现的零依赖、支持所有类型、 高性能、并发 mysqldump 工具。 <p align="center">
<img src="images/logo.png" width="200px"/>
<br>
<p align="center">
<img src="https://img.shields.io/github/stars/jarvanstack/mysqldump" />
<img src="https://img.shields.io/github/issues/jarvanstack/mysqldump" />
<img src="https://img.shields.io/github/forks/jarvanstack/mysqldump" />
</p>
</p>
## mysqldump
[简体中文](README-zh.md)
A zero-dependency,all data types are supported, high-performance, concurrent mysqldump tool implemented in golang.
## Features
* Supports custom Writer: data can be written to any Writer, such as local files, multiple file storage, remote servers, cloud storage, etc. (default console output).
* Supports all MySQL data types QuickStart.
* Support Merge Insert Option in Source Greatly improve data recovery performance
## QuickStart
### Create Table and Insert Test Data
```sql
DROP TABLE IF EXISTS `test`;
CREATE TABLE `test` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
`char_col` char(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
`varchar_col` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
`binary_col` binary(10) DEFAULT NULL,
`varbinary_col` varbinary(255) DEFAULT NULL,
`tinyblob_col` tinyblob,
`tinytext_col` tinytext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci,
`text_col` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci,
`blob_col` blob,
`mediumtext_col` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci,
`mediumblob_col` mediumblob,
`longtext_col` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci,
`longblob_col` longblob,
`enum_col` enum('value1','value2','value3') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
`set_col` set('value1','value2','value3') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
`bit_col` bit(8) DEFAULT NULL,
`tinyint_col` tinyint NOT NULL DEFAULT '0',
`bool_col` tinyint(1) NOT NULL DEFAULT '0',
`boolean_col` tinyint(1) NOT NULL DEFAULT '0',
`smallint_col` smallint NOT NULL DEFAULT '0',
`mediumint_col` mediumint NOT NULL DEFAULT '0',
`int_col` int NOT NULL DEFAULT '0',
`integer_col` int NOT NULL DEFAULT '0',
`bigint_col` bigint NOT NULL DEFAULT '0',
`float_col` float(8,2) NOT NULL DEFAULT '0.00',
`double_col` double(8,2) NOT NULL DEFAULT '0.00',
`decimal_col` decimal(10,2) NOT NULL DEFAULT '0.00',
`dec_col` decimal(10,2) NOT NULL DEFAULT '0.00',
`date_col` date DEFAULT NULL,
`datetime_col` datetime DEFAULT NULL,
`timestamp_col` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`time_col` time DEFAULT NULL,
`year_col` year DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
INSERT INTO `test` VALUES (1,'abc','def',0x61626300000000000000,0x646566,0x74696E79626C6F62,'Hello','World',0x776F726C64,'Medium Text',0x4D656469756D426C6F62,'Long Text',0x4C6F6E67426C6F62,'value2','value1,value3',0x66,-128,1,0,-32768,-8388608,-2147483648,-2147483648,-9223372036854775808,1234.56,1234.56,1234.56,1234.56,'2023-03-17','2023-03-17 10:00:00','2023-03-17 14:04:46','10:00:00',2023);
```
### Dump SQL
```go
import (
"os"
"github.com/jarvanstack/mysqldump"
)
func main() {
dsn := "root:rootpasswd@tcp(localhost:3306)/dbname?charset=utf8mb4&parseTime=true&loc=Asia%2FShanghai"
f, _ := os.Create("dump.sql")
_ = mysqldump.Dump(
dsn, // DSN
mysqldump.WithDropTable(), // Option: Delete table before create (Default: Not delete table)
mysqldump.WithData(), // Option: Dump Data (Default: Only dump table schema)
mysqldump.WithTables("test"), // Option: Dump Tables (Default: All tables)
mysqldump.WithWriter(f), // Option: Writer (Default: os.Stdout)
)
}
```
### Output File dump.sql
```sql
-- ----------------------------
-- MySQL Database Dump
-- Start Time: 2023-04-21 14:16:56
-- ----------------------------
USE `dc3`;
DROP TABLE IF EXISTS `test`;
-- ----------------------------
-- Table structure for test
-- ----------------------------
CREATE TABLE IF NOT EXISTS `test` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
`char_col` char(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
`varchar_col` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
`binary_col` binary(10) DEFAULT NULL,
`varbinary_col` varbinary(255) DEFAULT NULL,
`tinyblob_col` tinyblob,
`tinytext_col` tinytext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci,
`text_col` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci,
`blob_col` blob,
`mediumtext_col` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci,
`mediumblob_col` mediumblob,
`longtext_col` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci,
`longblob_col` longblob,
`enum_col` enum('value1','value2','value3') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
`set_col` set('value1','value2','value3') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
`bit_col` bit(8) DEFAULT NULL,
`tinyint_col` tinyint NOT NULL DEFAULT '0',
`bool_col` tinyint(1) NOT NULL DEFAULT '0',
`boolean_col` tinyint(1) NOT NULL DEFAULT '0',
`smallint_col` smallint NOT NULL DEFAULT '0',
`mediumint_col` mediumint NOT NULL DEFAULT '0',
`int_col` int NOT NULL DEFAULT '0',
`integer_col` int NOT NULL DEFAULT '0',
`bigint_col` bigint NOT NULL DEFAULT '0',
`float_col` float(8,2) NOT NULL DEFAULT '0.00',
`double_col` double(8,2) NOT NULL DEFAULT '0.00',
`decimal_col` decimal(10,2) NOT NULL DEFAULT '0.00',
`dec_col` decimal(10,2) NOT NULL DEFAULT '0.00',
`date_col` date DEFAULT NULL,
`datetime_col` datetime DEFAULT NULL,
`timestamp_col` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`time_col` time DEFAULT NULL,
`year_col` year DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- ----------------------------
-- Records of test
-- ----------------------------
INSERT INTO `test` VALUES (1,'abc','def',0x61626300000000000000,0x646566,0x74696E79626C6F62,'Hello','World',0x776F726C64,'Medium Text',0x4D656469756D426C6F62,'Long Text',0x4C6F6E67426C6F62,'value2','value1,value3',0x66,-128,1,0,-32768,-8388608,-2147483648,-2147483648,-9223372036854775808,1234.56,1234.56,1234.56,1234.56,'2023-03-17','2023-03-17 10:00:00','2023-03-17 14:04:46','10:00:00',2023);
-- ----------------------------
-- Dumped by mysqldump2
-- Cost Time: 5.81592ms
-- ----------------------------
```
### Source SQL
```go
import (
"os"
"github.com/jarvanstack/mysqldump"
)
func main() {
dsn := "root:rootpasswd@tcp(localhost:3306)/dbname?charset=utf8mb4&parseTime=true&loc=Asia%2FShanghai"
f, _ := os.Open("dump.sql")
_ = mysqldump.Source(
dsn,
f,
mysqldump.WithMergeInsert(1000), // Option: Merge insert 1000 (Default: Not merge insert)
mysqldump.WithDebug(), // Option: Print execute sql (Default: Not print execute sql)
)
}
```
", Assign "at most 3 tags" to the expected json: {"id":"1923","tags":[]} "only from the tags list I provide: [{"id":77,"name":"3d"},{"id":89,"name":"agent"},{"id":17,"name":"ai"},{"id":54,"name":"algorithm"},{"id":24,"name":"api"},{"id":44,"name":"authentication"},{"id":3,"name":"aws"},{"id":27,"name":"backend"},{"id":60,"name":"benchmark"},{"id":72,"name":"best-practices"},{"id":39,"name":"bitcoin"},{"id":37,"name":"blockchain"},{"id":1,"name":"blog"},{"id":45,"name":"bundler"},{"id":58,"name":"cache"},{"id":21,"name":"chat"},{"id":49,"name":"cicd"},{"id":4,"name":"cli"},{"id":64,"name":"cloud-native"},{"id":48,"name":"cms"},{"id":61,"name":"compiler"},{"id":68,"name":"containerization"},{"id":92,"name":"crm"},{"id":34,"name":"data"},{"id":47,"name":"database"},{"id":8,"name":"declarative-gui "},{"id":9,"name":"deploy-tool"},{"id":53,"name":"desktop-app"},{"id":6,"name":"dev-exp-lib"},{"id":59,"name":"dev-tool"},{"id":13,"name":"ecommerce"},{"id":26,"name":"editor"},{"id":66,"name":"emulator"},{"id":62,"name":"filesystem"},{"id":80,"name":"finance"},{"id":15,"name":"firmware"},{"id":73,"name":"for-fun"},{"id":2,"name":"framework"},{"id":11,"name":"frontend"},{"id":22,"name":"game"},{"id":81,"name":"game-engine "},{"id":23,"name":"graphql"},{"id":84,"name":"gui"},{"id":91,"name":"http"},{"id":5,"name":"http-client"},{"id":51,"name":"iac"},{"id":30,"name":"ide"},{"id":78,"name":"iot"},{"id":40,"name":"json"},{"id":83,"name":"julian"},{"id":38,"name":"k8s"},{"id":31,"name":"language"},{"id":10,"name":"learning-resource"},{"id":33,"name":"lib"},{"id":41,"name":"linter"},{"id":28,"name":"lms"},{"id":16,"name":"logging"},{"id":76,"name":"low-code"},{"id":90,"name":"message-queue"},{"id":42,"name":"mobile-app"},{"id":18,"name":"monitoring"},{"id":36,"name":"networking"},{"id":7,"name":"node-version"},{"id":55,"name":"nosql"},{"id":57,"name":"observability"},{"id":46,"name":"orm"},{"id":52,"name":"os"},{"id":14,"name":"parser"},{"id":74,"name":"react"},{"id":82,"name":"real-time"},{"id":56,"name":"robot"},{"id":65,"name":"runtime"},{"id":32,"name":"sdk"},{"id":71,"name":"search"},{"id":63,"name":"secrets"},{"id":25,"name":"security"},{"id":85,"name":"server"},{"id":86,"name":"serverless"},{"id":70,"name":"storage"},{"id":75,"name":"system-design"},{"id":79,"name":"terminal"},{"id":29,"name":"testing"},{"id":12,"name":"ui"},{"id":50,"name":"ux"},{"id":88,"name":"video"},{"id":20,"name":"web-app"},{"id":35,"name":"web-server"},{"id":43,"name":"webassembly"},{"id":69,"name":"workflow"},{"id":87,"name":"yaml"}]" returns me the "expected json"