2017 © Pedro Pelรกez
 

project sql

SQL Subcommand

image

xp-forge/sql

SQL Subcommand

  • Sunday, July 15, 2018
  • by thekid
  • Repository
  • 1 Watchers
  • 0 Stars
  • 8 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 5 Versions
  • 60 % Grown

The README.md

SQL subcommand

Build status on GitHub XP Framework Module BSD Licence Requires PHP 7.0+ Supports PHP 8.0+ Latest Stable Version, (*1)

SQL command line tool using XP database drivers., (*2)

Installation

$ composer global require xp-forge/sql 'dev-master'

Usage

$ xp help sql
@FileSystemCL<./src/main/php>
Runs SQL statements
โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

> Execute a single SQL statement and print the results

  $ xp sql 'sqlite://./test.db' 'select * from test'

> Change output mode by appending -m and one of csv, vert

  $ xp sql 'sqlite://./test.db' 'select * from test;-m csv'

> Read SQL statement from standard input using "-"

  $ cat statement.sql | xp sql 'sqlite://./test.db' -

> Use named connections as configured in connections.ini.

  $ xp sql dev-db 'select * from account where id = 1'


The file connections.ini is per-user and can be found in one of:

> %LOCALAPPDATA%/Xp-forge.sql/ on Windows
> $XDG_CONFIG_HOME/xp-forge.sql/ inside an XDG environment
> $HOME/.xp-forge.sql/ otherwise

Invoking without arguments shows a list of available drivers.

The -m [vert,csv] syntax is inspired by SQSH, see http://manpages.ubuntu.com/manpages/precise/man1/sqsh.1.html, (*3)

Drivers

$ xp sql
@FileSystemCL<./src/main/php>
Available drivers via rdbms.DefaultDrivers
โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

> mysql+x: rdbms.mysqlx.MySqlxConnection
  Connection to MySQL Databases

> mysql+std: rdbms.mysql.MySQLConnection
  Connection to MySQL Databases via ext/mysql

> sybase+x: rdbms.tds.SybasexConnection
  Connection to Sybase Databases via TDS 5.0

> mssql+x: rdbms.tds.MsSQLxConnection
  Connection to MSSQL Databases via TDS 7.0

> sqlite+3: rdbms.sqlite3.SQLite3Connection
  Connection to SQLite 3.x Databases via ext/sqlite3

Examples

$ xp sql 'sqlite://./test.db' 'create table test (
  id integer primary key autoincrement,
  name varchar
)'
Query OK, 0 rows affected (0.02 sec)

$ xp sql 'sqlite://./test.db' 'insert into test (name) values ("Timm")'
Query OK, 1 rows affected (0.02 sec)

$ xp sql 'sqlite://./test.db' 'select * from test where id = 1'
id: 1
name: "Timm"

1 rows in set (0.00 sec)

The Versions

15/07 2018

dev-master

9999999-dev http://xp-framework.net/

SQL Subcommand

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

module xp

15/07 2018

v0.4.0

0.4.0.0 http://xp-framework.net/

SQL Subcommand

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

module xp

15/07 2018

v0.3.0

0.3.0.0 http://xp-framework.net/

SQL Subcommand

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

module xp

30/05 2017

v0.2.0

0.2.0.0 http://xp-framework.net/

SQL Subcommand

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

module xp

30/05 2017

v0.1.0

0.1.0.0 http://xp-framework.net/

SQL Subcommand

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

module xp