Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

TODO is a simple web application that introduces you to the power, performance, and simplicity of MariaDB. The TODO app contains a React.js front-end and Python back-end, which utilizes the MariaDB Python connector and the SQLAlcemy object-relational mapping toolkit.

License

NotificationsYou must be signed in to change notification settings

mariadb-developers/todo-app-python-sqlalchemy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TODO is a web application that introduces you to the power, performance, and simplicity ofMariaDB.

This project uses theMariaDB Python connector in combination with theSQLAlchemy (SQL and object-relational mapping toolkit) to connect to and communicate to a MariaDB database instance.

This application is made of two parts:

  • Client
    • web UI that communicates with REST endpoints available through an API app (see below).
    • is a React.js project located in theclient folder.
  • API

This README will walk you through the steps for getting theTODO web application up and running using MariaDB.

Table of Contents

  1. Requirements
  2. Getting started with MariaDB
  3. Get the code
  4. Create the database and table
  5. Configure, build and run the apps
    1. Configure
    2. Create and activate a Python virtual environment
    3. Install Python packages
    4. Build and run the Python API app
    5. Build and run the Client app
  6. Support and contribution
  7. License

Requirements

This sample application requires the following to be installed/enabled on your machine:

1.) Getting Started with MariaDB

MariaDB is a community-developed, commercially supported relational database management system, and the database you'll be using for this application.

If you don't have a MariaDB database up and running you can find more information on how to download, install and start using a MariaDB database in theMariaDB Quickstart Guide.

2.) Get the code

First, usegit (through CLI or a client) to retrieve the code usinggit clone:

$ git clone https://github.com/mariadb-developers/todo-app-python-sqlalchemy.git

Next, because this repo uses agit submodule, you will need to pull theclient application using:

$ git submodule update --init --recursive

3.) Create the database and table

Connect to your MariaDB database (fromStep #2) and execute the following SQL scripts using the following options:

a.) Use theMariaDB command-line client to execute the SQL contained withinschema.sql.

Example command:

$ mariadb --host HOST_ADDRESS --port PORT_NO --user USER --password PASSWORD< schema.sql

OR

b.) Copy, paste and execute the raw SQL commands contained inschema.sql using aclient of your choice.

CREATEDATABASEtodo;CREATETABLEtodo.tasks (  idINT(11) unsignedNOT NULL AUTO_INCREMENT,  descriptionVARCHAR(500)NOT NULL,  completedBOOLEANNOT NULL DEFAULT0,PRIMARY KEY (id));

4.) Configure, Build and Run the App

This application is made of two parts:

  • Client
    • web UI that communicates with REST endpoints available through an API app (see below).
    • is a React.js project located in theclient (/src/client) folder.
  • API

The following steps,a throughe, will walk you through the process of configuring, building and running theapi andclient applications.

a.) Configure the app

Configure the MariaDB connection by adding an.env file to the project within the root folder.

Example implementation:

DB_HOST=<host_address>DB_PORT=<port_number>DB_USER=<username>DB_PASS=<password>DB_NAME=todo

Configuring the connection

The environmental variables from.env are used withintasks.py to confire theSQLAlchemy connection engine :

engine=sqlalchemy.create_engine("mariadb+mariadbconnector://{0}:{1}@{2}:{3}/{4}".format(os.getenv("DB_USER"),os.getenv("DB_PASS"),os.getenv("DB_HOST"),os.getenv("DB_PORT"),os.getenv("DB_NAME")),echo=True)

Configuring .env and tasks.py for the MariaDB cloud database serviceSkySQL

Note: MariaDB SkySQL requires SSL additions to connection. Details coming soon!

b.) Create and activate a Python virtual environment

A virtual environment is a directory tree which contains Python executable files and other files which indicate that it is a virtual environment. Basically, it's the backbone for running your Python Flask app.

Creation ofvirtual environments is done by executing the following command (within/src/api):

$ python3 -m venv venv

Tip: Tip: pyvenv is only available in Python 3.4 or later. For older versions please use thevirtualenv tool.

Before you can start installing or using packages in your virtual environment, you’ll need to activate it. Activating a virtual environment will put the virtual environment-specific python and pip executables into your shell’s PATH.

Activate the virtual environment using the following command (within/src/api):

$. venv/bin/activate activate

c.) Install Python packages

Flask is a micro web framework written in Python. It is classified as amicroframework because it does not require particular tools or libraries.

TL;DR It's what this app uses for the API.

This app also uses the MariaDB Python Connector to connect to and communicate with MariaDB databases.

Install the necessary packages by executing the following command (within/src/api):

$ pip3 install flask mariadb python-dotenv SQLAlchemy

d.) Build and run theAPI app

Once you've pulled down the code and have verified that all of the required packages are installed you're ready to run the application!

From/src/api execute the following CLI command to start the the Python project:

$ python3 api.py

Note: You will need to use seperate terminals for theclient andapi apps.

e.) Build and run theUI (Client) app

Once the API project is running you can now communicate with the exposed endpoints directly (via HTTP requests) or with the application UI, which is contained with theclient folder of this repo.

To start theclient application follow the instructionshere.

Support and Contribution

Please feel free to submit PR's, issues or requests to this project project directly.

If you have any other questions, comments, or looking for more information on MariaDB please check out:

Or reach out to us diretly via:

License

License

About

TODO is a simple web application that introduces you to the power, performance, and simplicity of MariaDB. The TODO app contains a React.js front-end and Python back-end, which utilizes the MariaDB Python connector and the SQLAlcemy object-relational mapping toolkit.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp