-
Notifications
You must be signed in to change notification settings - Fork 9
/
README.txt
84 lines (59 loc) · 2 KB
/
README.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
MS-SQL Command Line Interface (mssqlcli)
========================================
MS-SQL CLI is a unix command line tool for accessing and running arbitrary
queries against an Microsoft SQL database.
Binary Dependencies
-------------------
- [FreeTDS][1] - Binary Library providing access to MSSQL and Sybase DBs.
Installation
------------
1. Install the FreeTDS Library
- Debian/Ubuntu: sudo apt-get install freetds-dev
- Mac OSX: brew install freetds
2. Install pymssql
- pip install git+https://github.com/pymssql/pymssql.git
- This is currently necessary due to [A Bug in pymssql][4].
3. Clone this repo locally
4. Install client python setup.py install
Configuration
-------------
Configuration is handled with a single YAML configuration file, located by
default at ~/.config/mssqlcli.yml.
Example Config
--------------
keyring_app_name: another_app # Optional, defaults to mssqlcli
username: USE_KEYRING("global:LDAPUser")
password: USE_KEYRING("global:LDAP")
# OR
# username: my_plaintext_username
# password: my_plaintext_password
server: MY_MSSQL.example.com
# The below is optional, and should be used if
# Windows Auth will be used instead of MSSQL Auth.
windows_authentication: true
domain: MY_DOMAIN
Usage
-----
~ [ mssqlcli --help Usage: mssqlcli [OPTIONS] COMMAND [ARGS]...
Options:
--help Show this message and exit.
Commands:
query
~ [ mssqlcli query --help
Usage: mssqlcli query [OPTIONS] QUERY
Options:
-o, --output [json|csv]
-c, --config-file PATH Config File for use with client. (default:
~/.config/pymssql.yml)
--help Show this message and exit.
Examples
--------
Run Query and return results as a json blob
mssqlcli query {path to query}.sql
Run query and return results in CSV format
mssqlcli query -o csv {path to query}.sql
Redirect csv to File
mssqlcli query -o csv {path to query}.sql > results.csv
[1]: http://www.freetds.org/
[2]: http://pymssql.org/en/stable/
[3]: http://click.pocoo.org/5/