Skip to content

Commit cc9cdb0

Browse files
committed
Updates to Ruby and Python readme
1 parent 7988805 commit cc9cdb0

7 files changed

Lines changed: 230 additions & 56 deletions

File tree

Lines changed: 57 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,74 @@
1-
# Connect to SQL Database by using Python on Ubuntu Linux
1+
# Connect to SQL using Python on Ubuntu Linux
22

3-
[Python code sample] (sample_python_linux.py) that runs on an Ubuntu Linux client computer, to connect to an Azure SQL Database database.
3+
Python sample code that runs on an Ubuntu Linux client computer to connect to an Azure SQL Database using the **pymssql** connector.
44

5+
### Contents
56

6-
## Requirements
7+
[About this sample](#about-this-sample)<br/>
8+
[Before you begin](#before-you-begin)<br/>
9+
[Run this sample](#run-this-sample)<br/>
10+
[Sample details](#sample-details)<br/>
11+
[Disclaimers](#disclaimers)<br/>
12+
[Related links](#related-links)<br/>
713

814

9-
- [Python 2.7.6](https://www.python.org/download/releases/2.7.6/).
15+
<a name=about-this-sample></a>
1016

17+
## About this sample
1118

12-
### Install the required modules
19+
- **Applies to:** SQL Server 2016 (or higher), Azure SQL Database, Azure SQL Data Warehouse, Parallel Data Warehouse
20+
- **Workload:** CRUD
21+
- **Programming Language:** Python
22+
- **Authors:** Meet Bhagdev [meet-bhagdev]
1323

24+
<a name=before-you-begin></a>
1425

15-
Open your terminal and navigate to a directory where you plan on creating your python script. Enter the following commands to install **FreeTDS** and **pymssql**. pymssql uses FreeTDS to connect to SQL Databases.
26+
## Before you begin
1627

28+
To run this sample, you need the following prerequisites.
29+
30+
**Software prerequisites:**
31+
32+
1. SQL Server 2016 (or higher) or an Azure SQL Database
33+
2. Python
34+
35+
```
1736
sudo apt-get --assume-yes update
18-
sudo apt-get --assume-yes install freetds-dev freetds-bin
1937
sudo apt-get --assume-yes install python-dev python-pip
38+
```
39+
3. FreeTDS
40+
41+
```
42+
sudo apt-get --assume-yes install freetds-dev freetds-bin
43+
```
44+
45+
4. pymssql
46+
47+
```
2048
sudo pip install pymssql
49+
```
50+
51+
**Azure prerequisites:**
52+
53+
1. An AdventureWorks sample database:
54+
55+
- The Python sample relies on the AdventureWorks sample database. If you do not already have AdventureWorks, you can see how to create it at the following topic: [Create your first Azure SQL Database](http://azure.microsoft.com/documentation/articles/sql-database-get-started/)
56+
57+
## Run this sample
58+
59+
1. From your terminal, update the connection string details in the Python file with your own username, password, and hostname.
60+
61+
2. Run the code sample by running the below in your terminal:
62+
63+
```
64+
python sample_python_linux.py
65+
```
2166

67+
<a name=sample-details></a>
2268

23-
## Create a database and retrieve your connection string
69+
## Sample details
2470

71+
The above sample code just connected to your AdventureWorks database and performed a SELECT statement and an INSERT statement.
2572

26-
See the [getting started page](http://azure.microsoft.com/documentation/articles/sql-database-get-started/) to learn how to create a sample database and get your connection string. It is important you follow the guide to create an AdventureWorks database template. The samples shown below only work with the AdventureWorks schema.
73+
## Disclaimers
74+
The scripts and this guide are copyright Microsoft Corporations and are provided as samples. They are not part of any Azure service and are not covered by any SLA or other Azure-related agreements. They are provided as-is with no warranties express or implied. Microsoft takes no responsibility for the use of the scripts or the accuracy of this document. Familiarize yourself with the scripts before using them.
Lines changed: 53 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,71 @@
1-
# Connect to SQL Database by using Python on Mac OS
1+
# Connect to SQL using Python on macOS
22

3+
Python sample code that runs on an macOS client computer to connect to an Azure SQL Database using the **pymssql** connector.
34

4-
[Python code sample] (sample_python_mac.py) that runs on a Mac computer. The sample and connects to Azure SQL Database by using the **pymssql** driver.
5+
### Contents
56

7+
[About this sample](#about-this-sample)<br/>
8+
[Before you begin](#before-you-begin)<br/>
9+
[Run this sample](#run-this-sample)<br/>
10+
[Sample details](#sample-details)<br/>
11+
[Disclaimers](#disclaimers)<br/>
12+
[Related links](#related-links)<br/>
613

7-
## Requirements
814

15+
<a name=about-this-sample></a>
916

10-
- [Python 2.7.6](https://www.python.org/download/releases/2.7.6/).
11-
- [FreeTDS](https://github.com/brianb/FreeTDS)
12-
- [Pymssql](https://github.com/pymssql/pymssql)
17+
## About this sample
18+
- **Applies to:** SQL Server 2016 (or higher), Azure SQL Database, Azure SQL Data Warehouse, Parallel Data Warehouse
19+
- **Workload:** CRUD
20+
- **Programming Language:** Python
21+
- **Authors:** Meet Bhagdev [meet-bhagdev]
1322

14-
### Install the required modules
23+
<a name=before-you-begin></a>
1524

25+
## Before you begin
1626

17-
Open your terminal and install
27+
To run this sample, you need the following prerequisites.
1828

19-
**1) Homebrew**: Run the following command from your terminal. This will download the Homebrew package manager on your machine.
29+
**Software prerequisites:**
30+
1. Homebrew
31+
32+
```
33+
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
34+
```
2035

21-
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
22-
23-
**2) FreeTDS**: Run the following command from your terminal. This will download FreeTDS on your machine. FreeTDS is required for pymmsql to work.
36+
2. FreeTDS
2437

38+
```
2539
brew install FreeTDS
26-
27-
**3) Pymmsql**: Run the following command from your terminal. This will install pymmsql on your machine.
40+
```
41+
42+
3. tiny_tds
2843

44+
```
2945
sudo -H pip install pymssql
46+
```
47+
48+
**Azure prerequisites:**
49+
50+
1. An AdventureWorks sample database:
51+
52+
- The Python sample relies on the AdventureWorks sample database. If you do not already have AdventureWorks, you can see how to create it at the following topic: [Create your first Azure SQL Database](http://azure.microsoft.com/documentation/articles/sql-database-get-started/)
53+
54+
## Run this sample
55+
56+
1. From your terminal, update the connection string details in the Python file with your own username, password, and hostname.
57+
58+
2. Run the code sample by running the below in your terminal:
59+
60+
```
61+
python sample_python_mac.py
62+
```
63+
64+
<a name=sample-details></a>
3065

31-
## Create a database and retrieve your connection string
66+
## Sample details
3267

68+
The above sample code just connected to your AdventureWorks database and performed a SELECT statement and an INSERT statement.
3369

34-
See the [getting started page](http://azure.microsoft.com/documentation/articles/sql-database-get-started/) to learn how to create a sample database and get your connection string. It is important you follow the guide to create an **AdventureWorks database template**. The samples shown below only work with the **AdventureWorks schema**.
70+
## Disclaimers
71+
The scripts and this guide are copyright Microsoft Corporations and are provided as samples. They are not part of any Azure service and are not covered by any SLA or other Azure-related agreements. They are provided as-is with no warranties express or implied. Microsoft takes no responsibility for the use of the scripts or the accuracy of this document. Familiarize yourself with the scripts before using them.
Lines changed: 62 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,75 @@
1-
# Connect to SQL Database by using Python on Ubuntu Linux using pyodbc
1+
# Connect to SQL using Python on Ubuntu Linux
22

3-
[Python code sample] (sample_python_linux.py) that runs on an Ubuntu Linux client computer. The sample and connects to Microsoft SQL Database by using the **pyodbc** driver.
3+
Python sample code that runs on an Ubuntu Linux client computer to connect to an Azure SQL Database using the **pyodbc** connector.
44

5+
### Contents
56

6-
## Requirements
7+
[About this sample](#about-this-sample)<br/>
8+
[Before you begin](#before-you-begin)<br/>
9+
[Run this sample](#run-this-sample)<br/>
10+
[Sample details](#sample-details)<br/>
11+
[Disclaimers](#disclaimers)<br/>
12+
[Related links](#related-links)<br/>
713

814

9-
- [Python 2.7.6](https://www.python.org/download/releases/2.7.6/).
15+
<a name=about-this-sample></a>
1016

17+
## About this sample
1118

12-
### Install the required modules
19+
- **Applies to:** SQL Server 2016 (or higher), Azure SQL Database, Azure SQL Data Warehouse, Parallel Data Warehouse
20+
- **Workload:** CRUD
21+
- **Programming Language:** Python
22+
- **Authors:** Meet Bhagdev [meet-bhagdev]
1323

24+
<a name=before-you-begin></a>
1425

15-
Open your terminal and navigate to a directory where you plan on creating your python script. Enter the following commands to install **Microsoft ODBC Driver for SQL Server** and **pyodbc**. pyodbc uses the ODBC Driver to connect to SQL Databases.
26+
## Before you begin
1627

17-
sudo su
18-
wget https://gallery.technet.microsoft.com/ODBC-Driver-13-for-Ubuntu-b87369f0/file/154097/2/installodbc.sh
19-
sh installodbc.sh
20-
sudo -H pip install pyodbc
28+
To run this sample, you need the following prerequisites.
2129

30+
1. SQL Server 2016 (or higher) or an Azure SQL Database
31+
2. Python
2232

23-
## Create a database and retrieve your connection string
33+
```
34+
sudo apt-get --assume-yes update
35+
sudo apt-get --assume-yes install python-dev python-pip
36+
```
2437

25-
For simplicity we will create an Azure SQL Database for the sample. You can use the same sample for an on-premise SQL Server instance. See the [getting started page](http://azure.microsoft.com/documentation/articles/sql-database-get-started/) to learn how to create a sample database and get your connection string. It is important you follow the guide to create an AdventureWorks database template. The samples shown below only work with the AdventureWorks schema.
38+
3. Microsoft ODBC Driver for SQL Server
39+
40+
```
41+
sudo su
42+
wget https://gallery.technet.microsoft.com/ODBC-Driver-13-for-Ubuntu-b87369f0/file/154097/2/installodbc.sh
43+
sh installodbc.sh
44+
```
45+
46+
4. pyodc
47+
48+
```
49+
sudo -H pip install pyodbc
50+
```
51+
52+
**Azure prerequisites:**
53+
54+
1. An AdventureWorks sample database:
55+
56+
- The Python sample relies on the AdventureWorks sample database. If you do not already have AdventureWorks, you can see how to create it at the following topic: [Create your first Azure SQL Database](http://azure.microsoft.com/documentation/articles/sql-database-get-started/)
57+
58+
## Run this sample
59+
60+
1. From your terminal, update the connection string details in the Python file with your own username, password, and hostname.
61+
62+
2. Run the code sample by running the below in your terminal:
63+
64+
```
65+
python sample_python_linux.py
66+
```
67+
68+
<a name=sample-details></a>
69+
70+
## Sample details
71+
72+
The above sample code just connected to your AdventureWorks database and performed a SELECT statement and an INSERT statement.
73+
74+
## Disclaimers
75+
The scripts and this guide are copyright Microsoft Corporations and are provided as samples. They are not part of any Azure service and are not covered by any SLA or other Azure-related agreements. They are provided as-is with no warranties express or implied. Microsoft takes no responsibility for the use of the scripts or the accuracy of this document. Familiarize yourself with the scripts before using them.
Lines changed: 55 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,71 @@
1-
# Connect to SQL Database by using Python on Windows using pyodbc
1+
# Connect to SQL using Python on Windows
22

3+
Python sample code that runs on an Windowsclient computer to connect to an Azure SQL Database using the **pyodbc** connector.
34

4-
[Python code sample] (sample_python_windows.py) that runs on a Windows computer. The sample and connects to Microsoft SQL Database by using the **pyodbc** driver.
5+
### Contents
56

7+
[About this sample](#about-this-sample)<br/>
8+
[Before you begin](#before-you-begin)<br/>
9+
[Run this sample](#run-this-sample)<br/>
10+
[Sample details](#sample-details)<br/>
11+
[Disclaimers](#disclaimers)<br/>
12+
[Related links](#related-links)<br/>
613

7-
## Requirements
814

15+
<a name=about-this-sample></a>
916

10-
- [Python 2.7.6](https://www.python.org/download/releases/2.7.6/).
11-
- [ODBC Driver 11 or 13 for SQL Server Windows](https://www.microsoft.com/en-us/download/details.aspx?id=50420)
12-
- [Pyodbc](https://pypi.python.org/pypi/pyodbc/3.0.10)
17+
## About this sample
1318

14-
### Install the required modules
19+
- **Applies to:** SQL Server 2016 (or higher), Azure SQL Database, Azure SQL Data Warehouse, Parallel Data Warehouse
20+
- **Workload:** CRUD
21+
- **Programming Language:** Python
22+
- **Authors:** Meet Bhagdev [meet-bhagdev]
1523

16-
Navigate to your Python directory where the pip installer is located. For example C:\Python27\Scripts>.
24+
<a name=before-you-begin></a>
1725

18-
####Install pyodbc
26+
## Before you begin
1927

28+
To run this sample, you need the following prerequisites.
29+
30+
**Software prerequisites:**
31+
1. SQL Server 2016 (or higher) or an Azure SQL Database
32+
33+
2. Python
34+
- [Download from here](https://www.python.org/download/releases/2.7.6/)
35+
36+
3. Microsoft ODBC Driver 11 or 13 for SQL Server Windows
37+
- [Download from here](https://www.microsoft.com/en-us/download/details.aspx?id=50420)
38+
39+
4. [Pyodbc](https://pypi.python.org/pypi/pyodbc/3.0.10)
40+
41+
```
2042
pip install pyodbc
43+
```
44+
45+
*Note: Instructions to enable the use pip can be found [here](http://stackoverflow.com/questions/4750806/how-to-install-pip-on-windows)*
46+
47+
48+
**Azure prerequisites:**
49+
50+
1. An AdventureWorks sample database:
51+
52+
- The Python sample relies on the AdventureWorks sample database. If you do not already have AdventureWorks, you can see how to create it at the following topic: [Create your first Azure SQL Database](http://azure.microsoft.com/documentation/articles/sql-database-get-started/)
53+
54+
## Run this sample
55+
56+
1. From your terminal, update the connection string details in the Python file with your own username, password, and hostname.
57+
58+
2. Run the code sample by running the below in your terminal:
2159
22-
*Note: Instructions to enable the use pip can be found [here](http://stackoverflow.com/questions/4750806/how-to-install-pip-on-windows)*
60+
```
61+
python sample_python_windows.py
62+
```
2363
64+
<a name=sample-details></a>
2465
25-
## Create a database and retrieve your connection string
66+
## Sample details
2667
27-
For simplicity we will create an Azure SQL Database for the sample. You can use the same sample for an on-premise SQL Server instance. See the [getting started page](http://azure.microsoft.com/documentation/articles/sql-database-get-started/) to learn how to create a sample database and get your connection string. It is important you follow the guide to create an AdventureWorks database template. The samples shown below only work with the AdventureWorks schema.
68+
The above sample code just connected to your AdventureWorks database and performed a SELECT statement and an INSERT statement.
2869
29-
See the [getting started page](http://azure.microsoft.com/documentation/articles/sql-database-get-started/) to learn how to create a sample database and get your connection string. It is important you follow the guide to create an **AdventureWorks database template**. The samples shown below only work with the **AdventureWorks schema**.
70+
## Disclaimers
71+
The scripts and this guide are copyright Microsoft Corporations and are provided as samples. They are not part of any Azure service and are not covered by any SLA or other Azure-related agreements. They are provided as-is with no warranties express or implied. Microsoft takes no responsibility for the use of the scripts or the accuracy of this document. Familiarize yourself with the scripts before using them.

samples/connect/ruby/linux/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Sample name
1+
# Connect to SQL using Ruby on Ubuntu Linux
22

33
Ruby sample code that runs on an Ubuntu Linux client computer to connect to an Azure SQL Database.
44

@@ -26,7 +26,6 @@ To run this sample, you need the following prerequisites.
2626

2727
**Software prerequisites:**
2828

29-
<!-- Examples -->
3029
1. SQL Server 2016 (or higher) or an Azure SQL Database
3130
2. Ruby Version Manager
3231

samples/connect/ruby/mac/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Sample name
1+
# Connect to SQL using Ruby on macOS
22

33
Ruby sample code that runs on a macOS computer to connect to an Azure SQL Database.
44

samples/connect/ruby/windows/README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Sample name
1+
# Connect to SQL using Ruby on Windows
22

33
Ruby sample code that runs on a Windows computer to connect to an Azure SQL Database.
44

@@ -26,8 +26,6 @@ To run this sample, you need the following prerequisites.
2626

2727
**Software prerequisites:**
2828

29-
<!-- Examples -->
30-
3129
1. Ruby
3230
- [Go the Ruby download page](http://rubyinstaller.org/downloads/) and download the appropriate 2.1.x installer. For example if you are on a 64 bit machine, download the **Ruby 2.1.6 (x64)** installer.
3331
- Once the installer is downloaded, do the following:

0 commit comments

Comments
 (0)