for COMP 353/453
There are three modules in the course: Database Design and SQL;
Python-Flask-SQLAlchemy; and MongoDB. There is a general course
orientation, as well as specific orientation (installation) requirements for
each modules, as outlined below:
- General course orientation
editor of your choice (I am using Notepad++. You
may want to use Sublime, Atom or any other text editor.)
- Virtual Machine: All students may skip
installation entirely and simply use the Virtual Machine that is
available. Instructions for using the VM are on the
Orientation page on Sakai.You still have to submit Orientation
Screenshots, to demonstrate that you are able to login, to access your
database, to build a basic application using Flask, and so forth, but
you may do these activities using the Virtual Machine. Further,
it is not an "either/or" choice. You may install the environment
on your own computer, and you may also use a Virtual Machine when it
is convenient for you to do so, or in case you have any database
connection issues. Mac users in particular are encouraged to use
the VM if you any issues with installation on your Mac. over the past
few months, MongoDB has had some difficulties with Mac installation on
the newer Mac OS, so Mac users may want to use the VM for that.
- Module 1: Database design and
- Using XAMPP/MAMP (Apache/MySQL/PHP and Perl)
Why XAMPP? We're not using PHP!!!
- XAMPP is a convenient way to install MySQL (or its clone, MariaDB)
and Apache, without having to install each component separately and
getting them to work together.
- PHPMyAdmin widely used as a convenient GUI that comes with
XAMPP. It is used to manage/view/test MySQL databases, regardless of the application language.
- You could certainly use the localhost setup by XAMPP together with
your python programs. In our case, we will not, since it's
easier to use flask for that. But you certainly could, and
- Do you have to use XAMPP?
- NO! If you want to use WAMP-Server, or AMPS, or
even install each component separately, you may do so.
- Do you have to use PHPMYAdmin to see and work on my
database? What about IDLE for editing my Python code?
- NO! I will demonstrate many of our queries on PHPMyAdmin, and
use it for "quick-and-dirty" database checks, even when using
Python. You may use WorkBench, or HeidiSQL, or pyMySQL, of
Raspberry Pi, or PyCharm, or any type of database connection and
any IDE you want to use. If you use an alternative setup,
please make sure you can access and view your database, and send
similar screenshots to the ones required in this
orientation. Since we'll be installing Anaconda, you might
want to use Sypder, especially on the Mac, if you don't have a
separate Python 3 installation beyond Anaconda's. (Sypder
comes with your Anaconda installation.)
- Installing XAMPP on Ubuntu
- Please submit a
screenshot on Sakai, for the assignment named Orientation:
XAMPP/MAMP Installation screenshot , as per the
instructions in the assignment.
and set up a root user and a new user username and password .
Write down your root password and your new user username and pwd
- If you are using the VM, you do not have to configure phpmyadmin.
It is already configured. The username and password for phpmyadmin
on the VM is "student" and "student". You still have to test
the installation, just to show me that you know how to access
test your XAMPP/MAMP installation Please
take a screenshot (as per instructions) and submit on Sakai to the
assginment named Orientation:
Test MySQL/PHP Installation
test your command-line (Terminal) installation Please
take a screenshot (as per instructions) and submit on Sakai to the
assignment named Orientation:
Test Terminal (Command Line) Installation
- You may also want to install
SublimeText, atom, TextWrangler (or any
good text editor)
on the mac,
on Windows. (You can even install
Notepadd++ on the Mac, using Winebottler, but that's really out
of scope for this course.)
- For modeling your ER diagrams, use any modeling tool you want.
As a fallback position, you may use even
Word or PPT. MUCH BETTER: try ERDPlus (seems
cool and very clear!) has been a student favorite in past semesters;
(I don't prefer their EER notation, but no biggie); StarUML; ErDraw
EER notation) Dia (Windows or mac); Lucid (You
can keep renewing the free trial)
- Module 2: Python, Flask,
- Python: https://www.python.org/
There is a checkbox in the installation box to add Python to the
Windows path. Check that box!! See note below under
Installation of Database Packages, regarding some incompatibilities of
Python with some of the standard database packages.
- If you want to use PyCharm or any other IDE, feel free to do so, but
you are responsible for making sure that you can run flask, install
all packages, and connect to the database both through
flask_sqlalchemy and through the other database connectors that we use
It will redirect you to "products" and select the Anaconda Products
Individual, which will scroll you to the bottom of the page to
select your OS. As of this writing, it's using Python 3.9 for
Windows. For the Mac, be very careful to install the Anaconda
version for Python 3.x!!
Windows: I already had Python installed, and installing
Anaconda over my existing Python installation works just fine.
Python 2 comes installed with a Mac OS. However, you want
Python 3. You do not have to install it separately (although
you certainly may). When you install Anaconda 3, Python 3.x
will be installed, if you are careful to select the Python 3.x
version when you download/install.
Anaconda installation will give you an option to add python to the
path. Say "Yes"!!!
Anaconda will automatically add python and anaconda to the
$PATH. You can always check:
recommended to create a new “virtual environment” in Anaconda for
each project. For this course, I will
only use one environment; therefore I will be using the (base)
environment. Feel free to setup
multiple environments, but it is not required for this course, nor
will I demonstrate it.
installation: from within your
means, on Windows, Start-->Anaconda-->Anaconda prompt.
If you are using the VM, you have to run Anaconda as
administrator. Right-click the little Anaconda prompt
icon-->more--run as administrator). On Mac, start the
Anaconda Navigator, and open a terminal window. In both
cases, you should see the prompt with your acanconda environment,
for instance (base), as part of the prompt.)
into Python (type python at the command prompt, from within
import flask. There should be no error.
- Take a screenshot from within
Anaconda terminal/command, showing import flask with no error.
file which contains the sample code that you will need for
the Python ORM part of the course. Unzip. There will
be a few (very few) changes in the Mac version, so
here is the Mac zip file. The Virtual Machine
already has everything downloaded onto the Desktop.
However, if you mess it up or need a fresh version, here
is the VM zip file.
the first three minutes of the video, and duplicate the
- Take a screenshot of "Hello,
World!" on your web browser .
- Submit the import
Flask screenshot and
the Flask HelloWorld screenshot for the assignment named Orientation: Screenshot of
Fask Installation and HelloWorld.
- ***Please note: The
folder structure in the video is slightly different from the one
that I give you in the zip file that you downloaded. In
the video, the flaskHelloWorld.py program is in the folder
FlaskDemoLectures. However, I changed it slightly after
making the video. Your flaskHelloWorld.py program is in
Flask-Demo/Lectures/1-GettingStarted of your unzipped folder
structure. When I navigate to the folder containing the
flaskHelloDemo.py program, be sure that you navigate to the
folder where your
program is located
- Installation of database packages: (There are no specific
orientation assignments for this part, since Lab-4a-connect covers
this material. However, I am including it here, so that all
installation instructions are in one place, and also because you may
want to get things up and running earlier than required.
- Instructions for Windows users:
- MySQL connector: From within your Anaconda environment:
- Flask-mysqldb: We want to use Flask-mysqldb. It has
a dependency of Mysqlclient. On newer versions of
Flask-mysqldb the dependency will be installed when you type pip
install Flask-mysqldb. If this works for you, then you can
skip the rest of this document.
- If you could not install Flask-mysqldb because it requires you
to first install MySQLClient, then attempt the instructions below:
- From within your Anaconda environment, attempt:
You may get an error that you don't have the VB Build
Tools installed (I have not experienced that error
on the Mac, nor have I found others who have encountered
- Go to: https://visualstudio.microsoft.com/visual-cpp-build-tools/
- install as per instructions
- Close Anaconda terminal
- Run the Anaconda prompt as administrator
- right-click the prompt icon and select run as
- type: conda install -c bioconda mysqlclient
(Ignore any warnings about conda packages being
deprecated. It is a bug in conda and is being fixed
as of this writing.)
- you should then be able to pip install Flask-mysqldb
IMPORTANT NOTE: A student has encountered an
incompatibility error when trying to install mysqlclient
while using python 3.8 and later. This may indeed
be an incompatibility or it may be a conda thing.
Apparently, 3.8 and later is having some compatibility
issues with several packages (not just database ones).
So I tried this on a clean VM, using Anaconda with
Python 3.8.5 and then on 3.9, and I also got this
error. Before trying some of the suggestions
below, I just went ahead and did pip install
Flask-mysqldb, and lo and behold, it installed
Flask-mysqldb and also installed the dependency
mysqlclient!! If this works for you, you can
ignore the rest of this document.
- You can try to install MySQLClient manually. See this
video, with a link to where the package can be
downloaded and installed manually (not installed through
either PIP or Conda). Just be sure to install it
from within Anaconda.
You can opt to install python 3.6 instead. Or,
you can use python 3.10 (Anaconda currently running
PYthon 3.9) with everything else (I hope!!), and use the
VM for the few labs which require flask mysqldb (which
has mysqlclient as a dependency). I do know that
students ran everything successfully in the Fall, 2021,
- Instructions for Mac Users:
->BTW, Mac users. Sometimes,
there are just too many configuration issues or conflicts to
make this local installation worth your while. This is
especially the case in the more recent versions of Mac OS, as it
does not allow you to install in the root directoryYou may want to
seriously consider using the VM.
2 comes installed on macOS, however, you want Python
3. You do not have to install it separately (although
you certainly may). When you install Anaconda 3,
Python 3.x will be installed, if you are careful to select
the Python 3.x version when you download/install.
will automatically add python and anaconda to the
a terminal window (either by starting Anaconda Navigator or
a terminal app of your choosing), you should see the prompt
with your acanconda environment, for instance (base), as
part of the prompt.
- Flask installation:
- pip install flask
- pip install flask-sqlalchemy
- pip install flask-login
- pip install flask-bcrypt
- pip install flask-wtf
- Then go into Python (type python at the
command prompt, from within anaconda)
- type import flask. There should be no
- type import flask_sqlalchemy
- type exit()
- Take a screenshot from within Anaconda
terminal/command, showing import flask with no error.
- Download the Mac zip file
which contains the sample code that you will need for the
Python ORM part of the course. Unzip.
- Note: There will be a few (very
few) changes in the Mac version
- Installation of
database packages: (There
are no specific orientation assignments for this part, since
Lab-4a-connect covers this material. However, I am
including it here, so that all installation instructions are
in one place, and also because you may want to get things up
and running earlier than required. Recommended.
your Anaconda environment:
Client and MySQLdb:
within your Anaconda environment, attempt:
istall Flask-mysqldb. If you get an error that
mysqlclient is not installed try:
conda install -c bioconda mysqlclient (Ignore
any warnings about conda packages being
deprecated. It is a bug in conda and is being
fixed as of this writing, and in fact may be fixed by
the time you attempt the install.)
(install after MySQLClient is successfully installed):
As we build our applications, we may be required to install