Socket
Socket
Sign inDemoInstall

tuql

Package Overview
Dependencies
217
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    tuql

_Pronounced: Too cool_


Version published
Weekly downloads
1.3K
increased by0.78%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

tuql

Pronounced: Too cool

tuql is a simple tool that turns a sanely formatted sqlite database into a graphql endpoint. It tries to infer relationships between objects, currently supporting belongsTo, hasMany and belongsToMany. Currently, only read operations are supported (no mutations).

Installing

npm install -g tuql

Using

tuql --db path/to/database.sqlite

You can also optionally set the port and enable graphiql:

tuql --db path/to/database.sqlite --port 8888 --graphiql

Or, you can use a sql file with statements to build up an in-memory database:

tuql --infile path/to/db_dump.sql --graphiql

How it works

Imagine your sqlite schema looked something like this:

postsuserscategoriescategory_post
id  ididcategory_id
user_idusernametitlepost_id
title
body

tuql will automatically define models and associations, so that graphql queries like this will work right out of the box:

{
  posts {
    title
    body
    user {
      username
    }
    categories {
      title
    }
  }
}

tuql assumes the following about your schema:

  1. The primary key column is named id or thing_id or thingId, where thing is the singular form of the table name. Example: For a table named posts, the primary key column should be named id, post_id or postId.
  2. Similarly, foreign key columns should be thing_id or thingId, where thing is the singular form of the associated table.
  3. For many-to-many associations, the table name should be in the form of foo_bar or bar_foo (ordering is not important). The columns should follow the same pattern as #2 above.

Keywords

FAQs

Last updated on 20 Nov 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc