Giter Site home page Giter Site logo

MySQL sender about skogul HOT 4 CLOSED

KristianLyng avatar KristianLyng commented on August 14, 2024
MySQL sender

from skogul.

Comments (4)

u5surf avatar u5surf commented on August 14, 2024

I try this issue now, it is key point how replace from pq.CopyIn

I think it can replace into LOAD DATA LOCAL INFILE...
e.g.

func CopyInMySQL(table string, columns ...string) string {
	stmt := "LOAD DATA LOCAL INFILE ‘/dev/stdin’ " + QuoteIdentifier(table) + " ("
	for i, col := range columns {
		if i != 0 {
			stmt += ", "
		}
		stmt += quoteIdentifier(col)
	}
	stmt += ") TERMINATED BY ‘\n’ ENCLOSED BY ‘\“‘ ESCAPED BY ‘\“‘"
	return stmt

func quoteIdentifier(name string) string {
	end := strings.IndexRune(name, 0)
	if end > -1 {
		name = name[:end]
	}
	return `"` + strings.Replace(name, `"`, `""`, -1) + `"`
}

https://dev.mysql.com/doc/refman/5.6/ja/load-data.html

from skogul.

KristianLyng avatar KristianLyng commented on August 14, 2024

@u5surf I think you can get away with "INSERT INTO" within a transaction also. I did that with postgres in an earlier perl-based PoC and the performance was OK enough.

from skogul.

KristianLyng avatar KristianLyng commented on August 14, 2024

I've added a MySQL sender now that will most likely be renamed and made to support multiple databases. It's worth noting that this new sender is NOT in direct contest with the one relevant to this issue. The one that now exists only handles specific schemas/metrics, which is an important use case, but entirely distinct from this issue that deals with arbitrary input data.

from skogul.

KristianLyng avatar KristianLyng commented on August 14, 2024

Closing this as the actual sender works.

from skogul.

Related Issues (20)

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.