====== Python and SQLAlchemy ======
In this lab you will get to know the basics of Python and some of its most useful libraries. After completing this lab, you will be awarded the title of SQL Alchemist.
===== Lab Setup =====
- Open terminal
- Execute the script /opt/Uebungen/DatabaseLab/setup.sh
- Execute source ~/.bashrc
- Navigate to the folder for this lab: cd /home/lab/local-data/DatabaseLab
- Create and activate virtual environment
- conda create --name labEnvironment python=3.6 sqlalchemy sqlite pandas numpy matplotlib
- source activate labEnvironment
- Start notebook server jupyter notebook PythonSQL_Lab.ipynb
- Copy the link with the token and paste it into the browser's address bar
- Open the Notebook
===== Verifying Setup =====
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]].
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.
Let's verify that everything is working.
- 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 installed conda list
- Check that the Python version of the virtual environment is indeed 3.6 python -V
- Open the interactive Python interpreter ipython
- Print something print("Something")
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.
===== 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.
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!
===== Python Experts Listen Up! =====
If you are already familiar with Python, you can skip the Tutorial in the Jupyter Notebook and scroll down to the actual lab exercises!