sql-query-tag

Easy sql queries using tagged templates.

Usage no npm install needed!

<script type="module">
  import sqlQueryTag from 'https://cdn.skypack.dev/sql-query-tag';
</script>

README

sql-query-tag

Easy sql queries using tagged templates.

install

npm install any-db any-db-[adapter] sql-query-tag

Replace '[adapter]' with mssql, mysql, postgres or sqlite3.

usage

import SQLQueryTag from 'sql-query-tag';

const psql = SQLQueryTag('postgres://localhost/mydatabase');

// using promises
psql`SELECT * FROM posts`
  .then(posts => console.log(posts));

// using async/await
async function main() {
  let posts = await psql`SELECT * FROM posts`;
  ...
}

why

Wrapper using templates that promisifies the any-db library. Simple and easy to use sql queries, especially when using async/await.

license

MIT