Skip to content
This repository was archived by the owner on May 7, 2024. It is now read-only.

Commit 606053a

Browse files
authored
Merge release 1.0.0a21 (#155)
* Use SqlToolsService built on .NET Core 2.0 and a build script updates (#131) * Bump version to 1.0.0a19 * Use .NET Core 2.0 RTM built sqltoolsservice * Add build script to upload to azure blob storage * Upgrade to VS 2017 * Remove 3.3 as supported Python version * Fix perf issue where main event loop takes 100% of CPU (#132) Fix perf issue where main event loop takes 100% of CPU We have a 2 threads: Thread #1 runs in a loop polling the response queue Thread #2 runs in a loop decoding responses from the sqltoolsservice over stdout and posting them to the response queue Since thread #1 doesn't sleep, it's takes 100% CPU. In addition, running python 2.7 on windows, #2 doesn’t preempt the CPU due to #1 taking all of the CPU cycles, so no response is processed. Fix is simple – thread #1 needs to sleep so thread #2 can get scheduled and get it’s work done. * Refine event loop perf fix in main.py Refine event loop perf fix in main.py * Fixing regular expression Previous regex would result in release:a1 and release_version: 12. Modified the regex for part Release to only pick up lower case letters. * Adding missing forward slash on test pypi url * fixing typos/grammar (#138) fixing typos/grammar. * Updating to release version 1.0.0a20. * Create doc for official msft docs page * Updated documentation page with usage_guide * Added link to download adventureworks * Updated with sqlcmd usage * Added in run and cloud shell support * Update/consolidate linux install (#153) * universal linux wheel gen and setup update. * Updating version cfg. * Updating sqltoolsservice container. * Updating spacing for flake8. * Updating team email. (#154)
1 parent ad37035 commit 606053a

File tree

7 files changed

+126
-128
lines changed

7 files changed

+126
-128
lines changed

.bumpversion.cfg

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[bumpversion]
2-
current_version = 1.0.0a20
2+
current_version = 1.0.0a21
3+
34
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)((?P<release>[a-z]+))(?P<release_version>\d+)
45
serialize =
56
{major}.{minor}.{patch}{release}{release_version}

doc/documentation_page.md

+100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# Get Started with mssql-scripter
2+
3+
mssql-scripter is the command line equivalent of the widely used Generate Scripts Wizard experience in SSMS.
4+
5+
You can use mssql-scripter on Linux, macOS, Windows, and the Azure Cloud Shell to generate data definition language (DDL) and data manipulation language (DML) T-SQL scripts for database objects in SQL Server running anywhere, Azure SQL Database, and Azure SQL Data Warehouse. You can save the generated T-SQL script to a .sql file or pipe it to standard *nix utilities (for example, sed, awk, grep) for further transformations. You can edit the generated script or check it into source control and subsequently execute the script in your existing SQL database deployment processes and DevOps pipelines with standard multiplatform SQL command line tools such as sqlcmd.
6+
7+
## Install
8+
9+
For information about installation, please see the LINK/install guide/LINK.
10+
11+
The examples in this guide use the Adventureworks sample database. You can download the sample [here](https://www.microsoft.com/en-us/download/details.aspx?id=49502).
12+
13+
## Generate scripts
14+
Use mssql-scripter to generate scripts for database schema and/or data by including specific objects, targeting server versions/editions, and piping the script to files.
15+
16+
### Dump database object schema
17+
18+
# generate DDL scripts for all objects in the Adventureworks database and save the script to a file
19+
mssql-scripter -S localhost -d AdventureWorks -U sa
20+
21+
# alternatively, specify the schema only flag to generate DDL scripts for all objects in the Adventureworks database and save the script to a file
22+
mssql-scripter -S localhost -d AdventureWorks -U sa -f ./adventureworks.sql
23+
24+
### Dump database object data
25+
26+
# generate DDL scripts for all objects in the Adventureworks database and save the script to stdout.
27+
mssql-scripter -S localhost -d AdventureWorks -U sa --data-only
28+
29+
### Dump the database object schema and data
30+
31+
# script the database schema and data piped to a file.
32+
mssql-scripter -S localhost -d AdventureWorks -U sa --schema-and-data > ./adventureworks.sql
33+
34+
# execute the generated above script with sqlcmd
35+
sqlcmd -S mytestserver -U sa -i ./adventureworks.sql
36+
37+
### Include database objects
38+
39+
# generate DDL scripts for objects that contain 'Employee' in their name to stdout
40+
mssql-scripter -S localhost -d AdventureWorks -U sa --include-objects Employee
41+
42+
# generate DDL scripts for the dbo schema and pipe the output to a file
43+
mssql-scripter -S localhost -d AdventureWorks -U sa --include-objects dbo. > ./dboschema.sql
44+
45+
### Exclude database objects
46+
47+
# generate DDL scripts for objects that do not contain 'Sale' in their name to stdout
48+
mssql-scripter -S localhost -d AdventureWorks -U sa --exclude-objects Sale
49+
50+
### Target server version
51+
52+
# specify the version of SQL Server the script will be run against
53+
mssql-scripter -S myServer -d AdventureWorks -U myUser –-target-server-version "AzureDB" > myData.sql
54+
55+
### Target server edition
56+
57+
# specify the edition of SQL Server the script will be run against
58+
mssql-scripter -S localhost -d AdventureWorks -U myUser –-target-server-edition "Enterprise" > myData.sql
59+
60+
### Pipe a generated script to sed
61+
Note this example is for Linux and macOS usage.
62+
63+
# change a schema name in the generated DDL script
64+
# 1) generate DDL scripts for all objects in the Adventureworks database
65+
# 2) pipe generated script to sed and change all occurrences of SalesLT to SalesLT_test and save the script to a file
66+
mssql-scripter -S localhost -d Adventureworks -U sa | sed -e "s/SalesLT./SalesLT_test./g" > adventureworks_SalesLT_test.sql
67+
68+
### Script data to a file
69+
70+
# script all the data to a file.
71+
mssql-scripter -S localhost -d AdventureWorks -U sa --data-only > ./adventureworks-data.sql
72+
73+
### Set environment variables
74+
You can set environment variables for your connection string through the following steps:
75+
76+
77+
# set environment variable MSSQL_SCRIPTER_CONNECTION_STRING with a connection string.
78+
export MSSQL_SCRIPTER_CONNECTION_STRING='Server=myserver;Database=mydb;User Id=myuser;Password=mypassword;'
79+
mssql-scripter
80+
81+
# set environment variable MSSQL_SCRIPTER_PASSWORD so no password input is required.
82+
export MSSQL_SCRIPTER_PASSWORD='ABC123'
83+
mssql-scripter -S localhost -d AdventureWorks -U sa
84+
85+
## Generate and run scripts
86+
In this example you will generate a script, send it to a file, and execute the script.
87+
88+
Generate a script and send it to a file using mssql-scripter.
89+
# script all the data to a file.
90+
mssql-scripter -S localhost -d AdventureWorks -U sa --data-only > ./adventureworks-data.sql
91+
92+
Now that you have generated a script for your database objects, you can execute the script using sqlcmd such as in the example below.
93+
94+
# execute the script from the file.
95+
sqlcmd -S localhost -d AdventureWorks -U sa -i`./adventureworks-data.sql
96+
97+
You can find more details on using sqlcmd [here](https://docs.microsoft.com/en-us/sql/relational-databases/scripting/sqlcmd-use-the-utility).
98+
99+
## Use mssql-scripter in the Cloud Shell
100+
You can use mssql-scripter in the Azure Cloud Shell to generate scripter for Azure SQL DB, Azure SQL DW, and SQL Server instances in Azure VMs. [Connect to the Azure Cloud Shell](https://docs.microsoft.com/en-us/azure/cloud-shell/overview?view=azure-cli-latest). Once connected, you can use mssql-scripter in the terminal as you would in a local terminal.

mssqlscripter/__init__.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@
33
# Licensed under the MIT License. See License.txt in the project root for license information.
44
# --------------------------------------------------------------------------------------------
55

6-
__version__ = '1.0.0a20'
6+
7+
__version__ = '1.0.0a21'
8+

mssqltoolsservice/buildwheels.py

+8-12
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,16 @@
1717
from urllib.request import urlopen
1818

1919

20-
DOWNLOAD_URL_BASE = 'https://mssqlscripter.blob.core.windows.net/sqltoolsservice-08-16-2017/'
20+
21+
DOWNLOAD_URL_BASE = 'https://mssqlscripter.blob.core.windows.net/sqltoolsservice-10-12-2017/'
2122

2223
# Supported platform key's must match those in mssqlscript's setup.py.
2324
SUPPORTED_PLATFORMS = {
24-
'CentOS_7': DOWNLOAD_URL_BASE + 'microsoft.sqltools.servicelayer-centos-x64-netcoreapp2.0.tar.gz',
25-
'Debian_8': DOWNLOAD_URL_BASE + 'microsoft.sqltools.servicelayer-debian-x64-netcoreapp2.0.tar.gz',
26-
'Fedora_23': DOWNLOAD_URL_BASE + 'microsoft.sqltools.servicelayer-fedora-x64-netcoreapp2.0.tar.gz',
27-
'openSUSE_13_2': DOWNLOAD_URL_BASE + 'microsoft.sqltools.servicelayer-opensuse-x64-netcoreapp2.0.tar.gz',
28-
'OSX_10_11_64': DOWNLOAD_URL_BASE + 'microsoft.sqltools.servicelayer-osx-x64-netcoreapp2.0.tar.gz',
29-
'RHEL_7': DOWNLOAD_URL_BASE + 'microsoft.sqltools.servicelayer-rhel-x64-netcoreapp2.0.tar.gz',
30-
'Ubuntu_14': DOWNLOAD_URL_BASE + 'microsoft.sqltools.servicelayer-ubuntu14-x64-netcoreapp2.0.tar.gz',
31-
'Ubuntu_16': DOWNLOAD_URL_BASE + 'microsoft.sqltools.servicelayer-ubuntu16-x64-netcoreapp2.0.tar.gz',
32-
'Windows_7_64': DOWNLOAD_URL_BASE + 'microsoft.sqltools.servicelayer-win-x64-netcoreapp2.0.zip',
33-
'Windows_7_86': DOWNLOAD_URL_BASE + 'microsoft.sqltools.servicelayer-win-x86-netcoreapp2.0.zip'
34-
}
25+
'Linux_64': DOWNLOAD_URL_BASE + 'Microsoft.SqlTools.ServiceLayer-linux-x64-netcoreapp2.0.tar.gz',
26+
'OSX_10_11_64': DOWNLOAD_URL_BASE + 'Microsoft.SqlTools.ServiceLayer-osx-x64-netcoreapp2.0.tar.gz',
27+
'Windows_7_64': DOWNLOAD_URL_BASE + 'Microsoft.SqlTools.ServiceLayer-win-x64-netcoreapp2.0.zip',
28+
'Windows_7_86': DOWNLOAD_URL_BASE + 'Microsoft.SqlTools.ServiceLayer-win-x86-netcoreapp2.0.zip'
29+
3530

3631
CURRENT_DIRECTORY = os.path.abspath(os.path.join(os.path.abspath(__file__), '..'))
3732
BUILD_DIRECTORY = os.path.abspath(os.path.join(CURRENT_DIRECTORY, 'build'))
@@ -78,6 +73,7 @@ def build_sqltoolsservice_wheels(platforms):
7873
os.environ[u'MSSQLTOOLSSERVICE_PLATFORM'] = platform
7974

8075
print(u'Calling setup bdist_wheel for platform:{}'.format(platform))
76+
print(SUPPORTED_PLATFORMS[platform])
8177
download_and_unzip(SUPPORTED_PLATFORMS[platform], directory=TARGET_DIRECTORY)
8278
utility.exec_command(u'python setup.py check -r -s bdist_wheel', CURRENT_DIRECTORY)
8379

mssqltoolsservice/mssqltoolsservice/__init__.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
import os
1010
import platform
1111

12-
__version__ = '1.0.0a20'
12+
13+
__version__ = '1.0.0a21'
14+
1315

1416

1517
def get_executable_path():

mssqltoolsservice/setup.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212

1313
# This version number is in place in two places and must be in sync with
1414
# mssqlscripter's version in setup.py.
15-
MSSQLTOOLSSERVICE_VERSION = '1.0.0a20'
15+
16+
MSSQLTOOLSSERVICE_VERSION = '1.0.0a21'
17+
1618

1719
# If we have source, validate version numbers match to prevent
1820
# uploading releases with mismatched versions.

setup.py

+7-112
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414

1515
# This version number is in place in two places and must be in sync with
1616
# mssqltoolsservice's version in setup.py.
17-
MSSQLSCRIPTER_VERSION = '1.0.0a20'
17+
18+
MSSQLSCRIPTER_VERSION = '1.0.0a21'
19+
1820

1921
# If we have the source, validate our setup version matches source version.
2022
# This will prevent uploading releases with mismatched versions. This will
@@ -58,119 +60,12 @@
5860

5961
MSSQLTOOLSSERVICE_PACKAGE_NAME = 'mssqltoolsservice-{}=={}'
6062
MSSQLTOOLSSERVICE_PACKAGE_SUFFIX = [
61-
'CentOS_7',
62-
'Debian_8',
63-
'Fedora_23',
64-
'openSUSE_13_2',
6563
'OSX_10_11_64',
66-
'RHEL_7',
67-
'Ubuntu_14',
68-
'Ubuntu_16',
6964
'Windows_7_64',
70-
'Windows_7_86'
65+
'Windows_7_86',
66+
'Linux_64'
7167
]
7268

73-
LINUX_DISTRO_NO_VERSION = {
74-
'centos': 'CentOS_7',
75-
'ol': 'CentOS_7',
76-
'fedora': 'Fedora_23',
77-
'opensuse': 'OpenSUSE_13_2',
78-
'rhel': 'RHEL_7',
79-
'debian': 'Debian_8',
80-
}
81-
82-
LINUX_DISTRO_WITH_VERSION = {
83-
'ubuntu':
84-
{
85-
'14': 'Ubuntu_14',
86-
'16': 'Ubuntu_16'
87-
},
88-
'elementary':
89-
{
90-
'0.3': 'Ubuntu_14',
91-
'0.4': 'Ubuntu_16'
92-
},
93-
'elementaryOS':
94-
{
95-
'0.3': 'Ubuntu_14',
96-
'0.4': 'Ubuntu_16'
97-
},
98-
'linuxmint':
99-
{
100-
'18': 'Ubuntu_16'
101-
},
102-
'galliumos':
103-
{
104-
'2.0': 'Ubuntu_16'
105-
},
106-
}
107-
108-
109-
def _get_runtime_id_helper(name, version):
110-
"""
111-
Checks if linux distro name and version match to a supported package.
112-
"""
113-
if name in LINUX_DISTRO_NO_VERSION:
114-
return LINUX_DISTRO_NO_VERSION[name]
115-
116-
if name in LINUX_DISTRO_WITH_VERSION:
117-
for supported_version in LINUX_DISTRO_WITH_VERSION[name]:
118-
if version.startswith(supported_version):
119-
return LINUX_DISTRO_WITH_VERSION[name][supported_version]
120-
return None
121-
122-
123-
def _get_linux_distro_runtime_id(content):
124-
"""
125-
Parse content for linux distro run time id.
126-
"""
127-
name = None
128-
version = None
129-
id_like = None
130-
131-
# Try to find name, version and id_like best effort.
132-
for line in content.splitlines():
133-
key, value = line.rstrip().split('=')
134-
value = value.strip('"')
135-
if key == 'ID':
136-
name = value
137-
elif key == 'VERSION_ID':
138-
version = value
139-
elif key == 'ID_LIKE':
140-
id_like = value.split(' ')
141-
if name and version and id_like:
142-
break
143-
# First try the distribution name.
144-
run_time_id = _get_runtime_id_helper(name, version)
145-
146-
# If we don't understand it, try the 'ID_LIKE' field.
147-
if not run_time_id and id_like:
148-
for name in id_like:
149-
run_time_id = _get_runtime_id_helper(name, version)
150-
if run_time_id:
151-
break
152-
153-
return run_time_id
154-
155-
156-
def _get_linux_distro_from_file():
157-
"""
158-
Find linux distro based on
159-
https://www.freedesktop.org/software/systemd/man/os-release.html.
160-
"""
161-
os_release_info_file = None
162-
163-
if os.path.exists('/etc/os-release'):
164-
os_release_info_file = '/etc/os-release'
165-
elif os.path.exists('/usr/lib/os-release'):
166-
os_release_info_file = '/usr/lib/os-release'
167-
else:
168-
raise EnvironmentError('Error detecting Linux distro version.')
169-
170-
with io.open(os_release_info_file, 'r', encoding='utf-8') as os_release_file:
171-
content = os_release_file.read()
172-
return _get_linux_distro_runtime_id(content)
173-
17469

17570
def _get_runtime_id(
17671
system=_platform.system(),
@@ -191,7 +86,7 @@ def _get_runtime_id(
19186
run_time_id = 'OSX_10_11_64'
19287
elif system == 'Linux':
19388
if architecture == '64bit':
194-
run_time_id = _get_linux_distro_from_file()
89+
run_time_id = 'Linux_64'
19590

19691
return run_time_id
19792

@@ -244,7 +139,7 @@ def get_mssqltoolsservice_package_name(run_time_id=_get_runtime_id()):
244139
description='Microsoft SQL Scripter Command-Line Tool',
245140
license='MIT',
246141
author='Microsoft Corporation',
247-
author_email='sqlxplatclieng@microsoft.com',
142+
author_email='sqlcli@microsoft.com',
248143
url='https://github.com/Microsoft/sql-xplat-cli/',
249144
zip_safe=True,
250145
long_description=open('README.rst').read(),

0 commit comments

Comments
 (0)