Skip to content

Commit fad4226

Browse files
authored
Merge pull request #87 from akatesmith/azurehostedcontent
Python and all the sqlcmd
2 parents 823a398 + cb204fa commit fad4226

12 files changed

+316
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
[SQLCMD](https://docs.microsoft.com/sql/linux/sql-server-linux-connect-and-query-sqlcmd){:target="_blank"} is a command line tool that enables you to connect to SQL Server and run queries.
2+
3+
```terminal
4+
sudo su
5+
6+
#Download appropriate package for the OS version
7+
#Choose only ONE of the following, corresponding to your OS version
8+
9+
#RedHat Enterprise Server 6
10+
curl https://packages.microsoft.com/config/rhel/6/prod.repo > /etc/yum.repos.d/mssql-release.repo
11+
12+
#RedHat Enterprise Server 7
13+
curl https://packages.microsoft.com/config/rhel/7/prod.repo > /etc/yum.repos.d/mssql-release.repo
14+
15+
#RedHat Enterprise Server 8 and Oracle Linux 8
16+
curl https://packages.microsoft.com/config/rhel/8/prod.repo > /etc/yum.repos.d/mssql-release.repo
17+
18+
exit
19+
sudo yum remove unixODBC-utf16 unixODBC-utf16-devel #to avoid conflicts
20+
sudo ACCEPT_EULA=Y yum install msodbcsql17
21+
# optional: for bcp and sqlcmd
22+
sudo ACCEPT_EULA=Y yum install mssql-tools
23+
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
24+
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
25+
source ~/.bashrc
26+
# optional: for unixODBC development headers
27+
sudo yum install unixODBC-devel
28+
```
29+
30+
After installing SQLCMD, you can connect to Azure SQL DB using the following command:
31+
32+
```terminal
33+
sqlcmd -S your_server.database.windows.net -U your_user -P your_password -d your_database
34+
1> # You're connected! Type your T-SQL statements here. Use the keyword 'GO' to execute each batch of statements.
35+
```
36+
37+
This how to run a basic inline query. The results will be printed to the STDOUT.
38+
39+
```terminal
40+
sqlcmd -S your_server.database.windows.net -U your_user -P your_password -d your_database -Q "SELECT @@VERSION"
41+
```
42+
43+
```results
44+
------------------------------------------------------------
45+
Microsoft SQL Azure (RTM) - 12.0.2000.8
46+
May 15 2020 00:47:08
47+
Copyright (C) 2019 Microsoft Corporation
48+
49+
50+
(1 rows affected)
51+
```
52+
53+
> You have successfully installed SQL Server Command Line Utilities on your Red Hat machine!
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
[SQLCMD](https://docs.microsoft.com/sql/linux/sql-server-linux-connect-and-query-sqlcmd){:target="_blank"} is a command line tool that enables you to connect to SQL Server and run queries.
2+
3+
```terminal
4+
sudo su
5+
6+
#Download appropriate package for the OS version
7+
#Choose only ONE of the following, corresponding to your OS version
8+
9+
#SUSE Linux Enterprise Server 11 SP4
10+
#Ensure SUSE Linux Enterprise 11 Security Module has been installed
11+
zypper ar https://packages.microsoft.com/config/sles/11/prod.repo
12+
13+
#SUSE Linux Enterprise Server 12
14+
zypper ar https://packages.microsoft.com/config/sles/12/prod.repo
15+
16+
#SUSE Linux Enterprise Server 15
17+
zypper ar https://packages.microsoft.com/config/sles/15/prod.repo
18+
#(Only for driver 17.3 and below)
19+
SUSEConnect -p sle-module-legacy/15/x86_64
20+
21+
exit
22+
sudo ACCEPT_EULA=Y zypper install msodbcsql17
23+
# optional: for bcp and sqlcmd
24+
sudo ACCEPT_EULA=Y zypper install mssql-tools
25+
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
26+
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
27+
source ~/.bashrc
28+
# optional: for unixODBC development headers
29+
sudo zypper install unixODBC-devel
30+
```
31+
32+
After installing SQLCMD, you can connect to SQL Server using the following command:
33+
34+
```terminal
35+
sqlcmd -S your_database.database.windows.net -U your_user -P your_password -d your_database
36+
1> # You're connected! Type your T-SQL statements here. Use the keyword 'GO' to execute each batch of statements.
37+
```
38+
39+
This how to run a basic inline query. The results will be printed to the STDOUT.
40+
41+
```terminal
42+
sqlcmd -S your_database.database.windows.net -U your_user -P your_password -d your_database -Q "SELECT @@VERSION"
43+
```
44+
45+
```results
46+
------------------------------------------------------------
47+
Microsoft SQL Azure (RTM) - 12.0.2000.8
48+
May 15 2020 00:47:08
49+
Copyright (C) 2019 Microsoft Corporation
50+
51+
52+
(1 rows affected)
53+
```
54+
55+
> You have successfully installed SQL Server Command Line Utilities on your SLES machine!
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
[SQLCMD](https://docs.microsoft.com/sql/linux/sql-server-linux-setup-tools){:target="_blank"} is a command line utility that enables you to connect to SQL Server and run queries.
2+
3+
```terminal
4+
brew tap microsoft/mssql-release https://github.com/Microsoft/homebrew-mssql-release
5+
brew update
6+
HOMEBREW_NO_ENV_FILTERING=1 ACCEPT_EULA=Y brew install msodbcsql17 mssql-tools
7+
```
8+
9+
After installing SQLCMD, you can connect to SQL Server using the following command:
10+
11+
```terminal
12+
sqlcmd -S your_database.database.windows.net -U your_user -P your_password -d your_database
13+
1> # You're connected! Type your T-SQL statements here. Use the keyword 'GO' to execute each batch of statements.
14+
```
15+
16+
This how to run a basic inline query. The results will be printed to the STDOUT.
17+
18+
```terminal
19+
sqlcmd -S your_database.database.windows.net -U your_user -P your_password -d your_database -Q "SELECT @@VERSION"
20+
```
21+
22+
```results
23+
------------------------------------------------------------
24+
Microsoft SQL Azure (RTM) - 12.0.2000.8
25+
May 15 2020 00:47:08
26+
Copyright (C) 2019 Microsoft Corporation
27+
28+
29+
(1 rows affected)
30+
```
31+
32+
> You have successfully installed SQL Server Command Line Utilities on your macOS machine!
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
layout: page-steps
3+
language: Python
4+
title: macOS
5+
permalink: /python/mac/az/
6+
redirect_from:
7+
- /python/mac/az/step/
8+
- /python/mac/az/step/1
9+
---
10+
11+
> In this section, you create an Azure Hosted SQL Database. After that you will install the necessary dependencies to create Python apps with Azure SQL DB.
12+
13+
## Step 1.1 Create Azure Hosted SQL Database
14+
15+
{% include partials/setup_azure_sql_instance.md %}
16+
17+
## Step 1.2 Install Homebrew and Python
18+
19+
1. Install Homebrew.
20+
21+
{% include partials/install_homebrew.md %}
22+
23+
2. Restart the terminal session.
24+
25+
3. Install Python
26+
27+
```terminal
28+
brew install python
29+
```
30+
31+
```results
32+
==> Downloading https://homebrew.bintray.com/bottles/python-2.7.12.el_capitan.bottle.tar.gz
33+
34+
...
35+
36+
==> Caveats
37+
Pip and setuptools have been installed. To update them
38+
pip install --upgrade pip setuptools
39+
40+
You can install Python packages with
41+
pip install
42+
43+
==> Summary
44+
🍺 /usr/local/Cellar/python/2.7.12: 3,476 files, 46.7M
45+
```
46+
47+
> You now have Python installed! The next section will walk you through getting the tools to interact with your database.
48+
49+
## Step 1.3 Install the ODBC Driver and SQL Command Line Utility for Azure SQL DB
50+
51+
{% include partials/az-install_sqlcmd_mac.md %}
52+
53+
## Step 1.4 Install The Azure CLI and Login to Azure
54+
55+
{% include partials/download_azure_cli.md %}
56+
57+
> You have successfully installed the Python Driver on your Mac. You now have everything you need to start writing your Python apps with Azure SQL DB!
58+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
layout: page-steps
3+
language: Python
4+
title: macOS
5+
permalink: /python/mac/az/step/2
6+
---
7+
8+
{% include partials/python/az-crudunix.md %}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
layout: page-steps
3+
language: Python
4+
title: macOS
5+
permalink: /python/mac/az/step/3
6+
---
7+
8+
{% include partials/python/az-columnstoreunix.md %}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
layout: page-steps
3+
language: Python
4+
title: RHEL
5+
permalink: /python/rhel/az/
6+
redirect_from:
7+
- /python/rhel/az/step/
8+
- /python/rhel/az/step/1
9+
---
10+
11+
> In this section, you create an Azure Hosted SQL Database. After that you will install the necessary dependencies to create Python apps with Azure SQL.
12+
13+
## Step 1.1 Create Azure Hosted SQL Database
14+
15+
{% include partials/setup_azure_sql_instance.md %}
16+
17+
## Step 1.2 Install Python and other required packages
18+
19+
```terminal
20+
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
21+
sudo rpm -ivh epel-release-latest-7.noarch.rpm
22+
sudo yum install python python-pip python-wheel python-devel
23+
sudo yum group install "Development tools"
24+
```
25+
26+
> You now have Python installed! The next section will walk you through getting the tools to interact with your database.
27+
28+
## Step 1.3 Install the ODBC Driver and SQL Command Line Utility for SQL Server
29+
30+
{% include partials/az-install_sqlcmd_linux_rhel.md %}
31+
32+
33+
## Step 1.4 Install The Azure CLI and Login to Azure
34+
35+
{% include partials/download_azure_cli.md %}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
layout: page-steps
3+
language: Python
4+
title: RHEL
5+
permalink: /python/rhel/az/step/2
6+
---
7+
8+
{% include partials/python/az-crudunix.md %}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
layout: page-steps
3+
language: Python
4+
title: RHEL
5+
permalink: /python/rhel/az/step/3
6+
---
7+
8+
{% include partials/python/az-columnstoreunix.md %}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
layout: page-steps
3+
language: Python
4+
title: SLES
5+
permalink: /python/sles/az
6+
redirect_from:
7+
- /python/sles/az/step/
8+
- /python/sles/az/step/1
9+
---
10+
11+
> In this section, you create an Azure Hosted SQL Database. After that you will install the necessary dependencies to create Python apps with Azure SQL DB.
12+
13+
## Step 1.1 Create Azure Hosted SQL Database
14+
15+
{% include partials/setup_azure_sql_instance.md %}
16+
17+
## Step 1.2 Install Python and other required packages
18+
19+
Install Python
20+
21+
```terminal
22+
sudo zypper install python-pip python-devel gcc gcc-c++
23+
```
24+
25+
> You now have Python installed! The next section will walk you through getting the tools to interact with your database.
26+
27+
## Step 1.3 Install the ODBC Driver and SQL Command Line Utility for Azure SQL DB
28+
29+
{% include partials/az-install_sqlcmd_linux_sles.md %}
30+
31+
## Step 1.4 Install The Azure CLI and Login to Azure
32+
33+
{% include partials/download_azure_cli.md %}
34+
35+
> You have successfully installed the Python Driver on your SLES machine. You now have everything you need to start writing Python apps with Azure SQL DB!

0 commit comments

Comments
 (0)