Giter VIP home page Giter VIP logo

sql-converter's Introduction

SQL Converter

Usage

Using the converter you can quickly swap between writing application JS/PHP code and database SQL queries.

Want to try your query with different values? Slow debugging in-application? Paste the code and use SQL directly.

Once you're happy that the updated SQL works, copy the JS/PHP back into your application and get back to work!

Setup

If you want a copy to make changes or use the tool locally, you can clone the repository:

git clone [email protected]:lukesrw/sql-converter.git

Then run the Next.js development server:

npm run dev
# or
yarn dev
# or
pnpm dev

You can make your own modifications to the tool by updating /src/app/page.tsx.

If you build a fantastic feature make sure to pull request it, so others can see your contributions.

sql-converter's People

Contributors

lukesrw avatar

Watchers

 avatar

sql-converter's Issues

Add error handling for sql-formatter

Attempting to format with invalid SQL currently results in:

image

If sql-formatter provides end-user useful error messages then this should also be displayed somewhere.

Update README

Prior to open sourcing I need to update the README with useful information.

  • Purpose
  • Usage
  • Installation
  • Video Demo?

Escaped queries aren't properly parsed

For example, PHP:

$query = $Database->query(
    'SELECT
		*
    FROM
		TableName
	WHERE
		TableName.FieldName = \'Test\''
);

Results in, SQL:

SELECT
	*
FROM
	TableName
WHERE
	TableName.FieldName = \

Language Variable Overrides

Currently conversion to other languages maintains the variable value, for example PHP:

$query = $Database->prepare(
    'SELECT * FROM TableName WHERE ColumnName = :Foo'
);

$query->execute(array(
    ':Foo' => $FooValue
));

Is converted into SQL:

SET @Foo = '$FooValue';

SELECT * FROM TableName WHERE ColumnName = @Foo

If you were to change the @Foo = '$FooValue' to test the query, for example @Foo = 'Test', the PHP would update as:

$query = $Database->prepare(
    'SELECT * FROM TableName WHERE ColumnName = :Foo'
);

$query->execute(array(
    ':Foo' => 'Test'
));

A useful feature would be the ability to lock-in variable values that are specific to the language.

In this case, I could've set that regardless of the other textareas the PHP value should always be $FooValue.

PHP Variable Quotes

Pasting the following PHP into the textarea:

$query = $Database->prepare(
    'SELECT * FROM TableName WHERE ColumnName = :Foo'
);

$query->execute(array(
    ':Foo' => $Test
));

Is parsed properly, but reads back as:

$query = $Database->prepare(
    'SELECT * FROM TableName WHERE ColumnName = :Foo'
);

$query->execute(array(
    ':Foo' => '$Test'
));

Variable values in the PHP output should not be quote escaped if they begin with a dollar sign.

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.