npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

azure-tables-query

v0.1.5

Published

Queries SQL into Azure Tables

Downloads

141

Readme

azure-tables-query

Queries SQL into Azure Tables

Installation

CLI

npm:

npm install --global azure-tables-query

yarn:

yarn add global azure-tables-query

API

npm:

npm install azure-tables-query

yarn:

yarn add azure-tables-query

Usage

This module can be used in two formats: CLI and API.

CLI

Account

To connect with an storage account you need first to inform the credentials with the account command:

aztb account
set <storage account name> <storage account key>

Saves a new Storage Account name and key for future connections

list

Lists all saved Storage Account names

delete <storage account name>

Removes a credential for a Storage Account

Connect

Connect to a local mirror of the Azure Tables of a storage Account to make SQL queries. Creates a CSVQL CLI session:

aztb connect <storage account name> [--fetch]

The flag --fetch is for update the local data before making a session, its recommended to use if you haven't updated the local copy soon.

Commands

The session have 4 commands:

Help

Prints all the available commands.

aztb> help
select <sql query>: Queries into imported schemas.
schema <operation>: Manage the schemas of the current session.
  list: List all tables and columns available.
  import <path [as <tableName>[, ...]]>: Import a new schema from CSV file(s).
  drop <tableName>: Delete a table of the current session.
  rename <tableName> <newTableName>: Rename a table of the current session.
help: List all available commands.
exit: Close the current session.
Exit

Close the application, equivalent of ^C.

Schema

Manages the schemes on the current session

Operations

list

List all the tables on current session, with the types.

import

Import CSV files, follows the syntax:

aztb> schema import path/to/file.csv [as table] [, ...]

rename

Rename a table on current session.

drop

Delete a table on current session.

Select

SQL SELECT Query, from sqlite.

API

Initialization

// Importing
const createTableSQL = require('azure-tables-query');

// Initialize
const tables = createTableSQL(
    storageAccountName,
    storageAccountKey,
    databasePath
);

storageAccountName and storageAccountKey

The credentials of your storage account.

databasePath

The path to where the SQLite database will be stored.

const databasePath = 'path/to/file';

Methods

fetch

Sync local database with Azure Tables. Required on first run:

await tables.fetch();
getClient

Get the CSVQL client to perform SQL operations:

const client = await tables.getClient();

Client Functions

schema

list

List all tables on current session

const result = await client.schema('list');

Return:

[
	{
		name: 'tableName',
		columns: [
			partitionKey: 'foo',
            rowKey: 'bar',
            timestamp: 'baz'
            ...
		]
	},
	...etc
]

rename

Rename a table on current session

await client.schema('rename', 'oldName', 'newName');

import

await client.schema('import', 'path/to/file');

drop

Delete a table on current session

await client.schema('drop', 'tableName');
select

Run SQL-like SELECT's, as example:

const result = await client.select('* from tableName');

The result will be the same as the better-sqlite3 module, with the format:

[
	{
		column: 'value'
	}
]