User Tools

Site Tools


labs:sqlalchemy

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
labs:sqlalchemy [2017/05/18 17:30]
brunnegi
labs:sqlalchemy [2020/08/31 21:03] (current)
Line 4: Line 4:
  
  
-====== Lab Setup ======+===== Lab Setup =====
  
   - Open terminal   - Open terminal
-  - Execute <​code> ​./​opt/​Uebungen/​DatabaseLab/​setup.sh </​code>​+  - Execute ​the script ​<​code>​ /​opt/​Uebungen/​DatabaseLab/​setup.sh </​code>​
   - Execute <​code>​ source ~/.bashrc </​code>​   - Execute <​code>​ source ~/.bashrc </​code>​
-  - Navigate to the folder for this lab: <​code>​ cd local-data/​DatabaseLab </​code>​+  - Navigate to the folder for this lab: <​code>​ cd /home/lab/local-data/​DatabaseLab </​code>​
   - Create and activate virtual environment ​   - Create and activate virtual environment ​
   - <​code>​conda create --name labEnvironment python=3.6 sqlalchemy sqlite pandas numpy matplotlib   - <​code>​conda create --name labEnvironment python=3.6 sqlalchemy sqlite pandas numpy matplotlib
-source activate labEnvironment</​code>​ +</​code>​ 
-  - Start notebook server <​code>​ jupyter notebook PythonSQL_Lab </​code>​+  - <​code> ​source activate labEnvironment </​code>​ 
 +  - Start notebook server <​code>​ jupyter notebook PythonSQL_Lab.ipynb ​</​code>​
   - Copy the link with the token and paste it into the browser'​s address bar   - Copy the link with the token and paste it into the browser'​s address bar
   - Open the Notebook   - Open the Notebook
Line 19: Line 20:
  
  
-===== Getting Started ​=====+===== Verifying Setup =====
  
-Ubuntu comes pre-installed ​with Python 2 and 3. It can also easily be installed using apt-get. However, these are system wide installations that are used by all Python programs. Since Python heavily relies on external libraries, and not all libraries are compatible with all versions of Python, it is often necessary to use different versions of Python for different projects. Thus, the use of Virtual Environments is highly encouraged. Every virtual environment has its own Python distributions and installed libraries. This way, different projects can be cleanly separated. There are several tools to create and manage virtual environments. ​+Ubuntu comes with pre-installed ​distributions of Python 2 and 3. It can also easily be installed using apt-get. However, these are system wide installations that are used by all Python programs. Since Python heavily relies on external libraries, and not all libraries are compatible with all versions of Python, it is often necessary to use different versions of Python for different projects. Thus, the use of Virtual Environments is highly encouraged. Every virtual environment has its own Python distributions and installed libraries. This way, different projects can be cleanly separated. There are several tools to create and manage virtual environments. ​
 In this lab we will use [[https://​conda.io/​docs/​using/​envs.html|Anaconda]]. In this lab we will use [[https://​conda.io/​docs/​using/​envs.html|Anaconda]].
- 
-Follow the link to figure out how to create and activate a new virtual environment. Specify the Python version to be 3.6 and install the following libraries using pip: 
-  * sqlalchemy 
-  * sqlite3 
-  * pandas 
-  * numpy 
-  * matplotlib 
- 
-The command you need to use is: 
- 
-<​code>​ conda create --name labEnvironment python=3.6 sqlalchemy sqlite pandas numpy matplotlib 
-</​code>​ 
  
 When programming with Python, one has the choice to use IDEs (Integrated Development Enviroments),​ text editors, an interactive python interpreter or more advanced tools like Jupyter Notebooks. In this lab, we will use the latter. ​ When programming with Python, one has the choice to use IDEs (Integrated Development Enviroments),​ text editors, an interactive python interpreter or more advanced tools like Jupyter Notebooks. In this lab, we will use the latter. ​
Line 40: Line 29:
 Let's verify that everything is working. ​ Let's verify that everything is working. ​
  
-  - Open a terminal window and activate ​your virtual environment ​<​code>​ source activate labEnvironment </​code>​ +  - Open a terminal window and make sure that your virtual environment ​is activated 
-  - List all installed packages and verify that sqlalchemy, sqlite3, pandas, numpy and matplotlib are instaleld ​<​code>​conda list</​code>​+  - List all installed packages and verify that sqlalchemy, sqlite3, pandas, numpy and matplotlib are installed ​<​code>​conda list</​code>​
   - Check that the Python version of the virtual environment is indeed 3.6 <​code>​python -V</​code>​   - Check that the Python version of the virtual environment is indeed 3.6 <​code>​python -V</​code>​
   - Open the interactive Python interpreter <​code>​ipython</​code>​   - Open the interactive Python interpreter <​code>​ipython</​code>​
Line 47: Line 36:
  
 If everything is set up correctly, you should see the print statement'​s output in the terminal. If everything is set up correctly, you should see the print statement'​s output in the terminal.
- 
-  - Open a text editor 
-  - Add a print statement <​code>​print("​Something Else"​)</​code>​ 
-  - Save the file as print.py 
-  - Inside the terminal, navigate to the location where you saved print.py and execute the script <​code>​python print.py</​code>​ 
- 
-If everything is set up correctly, you should see the print statement'​s output in the terminal. 
- 
 Now that all is set up, you are ready for the next step.  Now that all is set up, you are ready for the next step. 
  
-===== Jupyter Notebook ​===== +===== SQLAlchemy Lab ===== 
-As mentioned earlier, there are many ways to code Python. In this lab you will be introduced to Jupyter Notebooks. A powerful and convenient method for programming with Python. ​All you need to do is open a terminal and navigate to the ''/​home/​lab/​local-data/​DatabaseLab/''​ directory where all the contents ​of this lab are stored. Thenissue following command:+As mentioned earlier, there are many ways to code Python. In this lab you will be introduced to Jupyter Notebooks. A powerful and convenient method for programming with Python. 
 +We have already opened ​the notebook in the browser.  
 +For the remainder ​of this lab, you will be working in the Jupyter Notebook. Just follow the instructions there. Have fun!
  
-<​code>​jupyter notebook PythonSQL_Lab.ibynb 
-</​code>​ 
  
-This should start the Jupyter Notebook server on Localhost and automatically open a browser window. If the browser is not opened automatically,​ open one yourself and type the following in the address bar:  
  
-<​code>​http://​localhost:​8888/​notebooks/​PythonSQL_Lab.ipynb +===== Python Experts Listen Up! ===== 
-</​code>​ +If you are already familiar with Python, you can skip the Tutorial ​in the Jupyter Notebook ​and scroll down to the actual lab exercises!
- +
-For the remainder of this lab, you will be working ​in the Jupyter Notebook. Just follow ​the instructions there. Have fun!+
labs/sqlalchemy.1495121450.txt.gz · Last modified: 2020/08/31 21:03 (external edit)