Code Monkey home page Code Monkey logo

mysql-update-insert-transform's Introduction

mysql-update-insert(-ajax)-transform

A tool for transforming MySQL insert statements to update statements and vice versa.

In MySQL Workbench, as with probably many other tools, you are able to output insert and update statements. This is helpful, but you will have to edit in all the substitutions for prepared statements again. With this tool you only need to write either insert or an update statement and the tool will transform it to the other form.

The tool is also supposed to produce exactly what MySQL Workbench would produce... well some spaces are missing after transformation, otherwise it is 95% similar to the MySQL Workbench output.

The tool is not too strict about syntax, but might break in some cases. The more correct the syntax the better the app will work.

NOTE: You should probably be using 'UPSERT' pattern to begin with than to write separate insert and update statements, but in case you have to write them separately for some reason, this tool will help.

Tool online

The tool can be found online, here: click

Version 2

  • Implemented a shareable link generation
  • Implemented SQL to ajax transform
  • Implemented ajax to SQL transform
  • Fixed some edge cases with queries and ajax that broke the app

Version 3

  • Implemented function generator
  • Bugfixes

Examples

V2

V3

V3b

Example inputs

Insert

Link

INSERT INTO `somedb`.`sometable`
(`somecolumnA`,
`somecolumnB`,
`somecolumnC`,
`somecolumnD`,
`somecolumnE`,
`somecolumnF`,
`somecolumnG`,
`somecolumnH`)
VALUES
(:somesubstitutionA,
:somesubstitutionB,
:somesubstitutionC,
:somesubstitutionD,
:somesubstitutionE,
:somesubstitutionF,
:somesubstitutionG,
:somesubstitutionH);

Update

Link

UPDATE `somedb`.`sometable`
SET
`somecolumnA` = :somesubstitutionA,
`somecolumnB` = :somesubstitutionB,
`somecolumnC` = :somesubstitutionC,
`somecolumnD` = :somesubstitutionD,
`somecolumnE` = :somesubstitutionE,
`somecolumnF` = :somesubstitutionF,
`somecolumnG` = :somesubstitutionG,
`somecolumnH` = :somesubstitutionH
WHERE `someid` = :somevalue;

Ajax

Link

$.ajax(
{
	type: "type",
	url: "url",
	data:
	{
		somecolumnA: :somesubstitutionA,
		somecolumnB: :somesubstitutionB,
		somecolumnC: :somesubstitutionC,
		somecolumnD: :somesubstitutionD,
		somecolumnE: :somesubstitutionE,
		somecolumnF: :somesubstitutionF,
		somecolumnG: :somesubstitutionG,
		somecolumnH: :somesubstitutionH
	}
});

mysql-update-insert-transform's People

Contributors

ahvonenj avatar

Stargazers

 avatar

Watchers

 avatar  avatar

mysql-update-insert-transform's Issues

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.