Skip to content

Is there a tool to convert a sql script into a Golang SQL statement? #789

@kaihendry

Description

@kaihendry

Issue description

I'm puzzled how to run a client's multiline sql script he provides me in light of #258 (comment)

Example code

Here's a simple example, a script foobar.sql containing:


INSERT INTO `ut_test_foo_bar`(`foobar_invitation_id`) 
    VALUES 
    (@foo_bar_invitation_id);

Typically this file is hundreds of lines.

Error log

Tbh, I haven't even't figured out how to transform the quotes.

I'm manually reprogramming each line like so:

    result, err := db.Exec(
        "INSERT INTO ut_test_foo_bar (foobar_invitation_id) VALUES (?)",
        "blah blah blah",
    )

Which is super time consuming!!

Configuration

Driver version (or git SHA):

1a676ac

Go version: run go version in your console

go version go1.10.1 linux/amd64 (running Archlinux)

Server version: Server version: 5.7.12-log MySQL Community Server (GPL)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions