{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "from pandas import datetime\n",
    "import seaborn as sns\n",
    "from ipywidgets import interact\n",
    "import matplotlib.pyplot as plt\n",
    "%matplotlib inline\n",
    "import pyodbc\n",
    "import adodbapi\n",
    "%load_ext sql\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# MSSQL Management Studio Connection\n",
    "\n",
    "conn = pyodbc.connect('Driver={SQL server};'\n",
    "                      'server=DESKTOP-DS7J579\\PYTHON_DA;'\n",
    "                      'Database=AdventureWorks2012;'\n",
    "                      'uid=PyXXXXXXXX;'\n",
    "                      'pwd=PyXXXXXXXX;'\n",
    "                      'trusted_connection=yes')\n",
    "cursor = conn.cursor()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# Sample SQL Data pull\n",
    "\n",
    "df = pd.read_sql_query('select FirstName,'\n",
    "                       'LastName,'\n",
    "                       'City,'\n",
    "                       'StateProvinceName '\n",
    "                        'from Sales.vIndividualCustomer',conn)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>FirstName</th>\n",
       "      <th>LastName</th>\n",
       "      <th>City</th>\n",
       "      <th>StateProvinceName</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Aaron</td>\n",
       "      <td>Adams</td>\n",
       "      <td>Downey</td>\n",
       "      <td>California</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Adam</td>\n",
       "      <td>Adams</td>\n",
       "      <td>Newport Beach</td>\n",
       "      <td>California</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Alex</td>\n",
       "      <td>Adams</td>\n",
       "      <td>Lake Oswego</td>\n",
       "      <td>Oregon</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Alexandra</td>\n",
       "      <td>Adams</td>\n",
       "      <td>Burlingame</td>\n",
       "      <td>California</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Allison</td>\n",
       "      <td>Adams</td>\n",
       "      <td>Roubaix</td>\n",
       "      <td>Nord</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   FirstName LastName           City StateProvinceName\n",
       "0      Aaron    Adams         Downey        California\n",
       "1       Adam    Adams  Newport Beach        California\n",
       "2       Alex    Adams    Lake Oswego            Oregon\n",
       "3  Alexandra    Adams     Burlingame        California\n",
       "4    Allison    Adams        Roubaix              Nord"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Display Query\n",
    "\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}