Flask Database Manager by Problem Fighter Library
Project description
In the name of God, the Most Gracious, the Most Merciful.
PF-Flask-DB
Problem Fighter PF Flask DB (PF-Flask-DB) basically started with a Wrapper of Flask SQLAlchemy, When we try to create a project using Flask that moment we have to think about many area, such as Database, ORM, Migration etc. It's make developer life difficult, this project aim to integrate various library and provide a single but useful solution.
Example Codes
from flask import Flask
from pf_flask_db.pf_app_model import AppModel
from pf_flask_db.pf_app_database import app_db
app = Flask(__name__)
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///pf-flask-db-quick-start.sqlite"
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
app_db.init_app(app)
class Person(AppModel):
first_name = app_db.Column(app_db.String(150), nullable=False)
last_name = app_db.Column(app_db.String(150))
email = app_db.Column(app_db.String(120), nullable=False)
age = app_db.Column(app_db.Integer)
income = app_db.Column(app_db.Float, default=0)
with app.app_context():
app_db.create_all()
@app.route('/')
def bismillah():
return "PF Flask DB Tutorial"
@app.route('/create')
def create():
person = Person(first_name="First Name", last_name="Last Name", email="hmtmcse.com@gmail.com", age=22, income=500)
person.save()
response = "Data successfully Inserted"
return response
@app.route('/update')
def update():
person = Person.query.filter_by(id=1).first()
if person:
person.first_name = "FName Update"
person.last_name = "LName Update"
person.save()
return "Data has been updated."
@app.route('/delete')
def delete():
person = Person.query.filter_by(id=1).first()
if person:
person.delete()
return "Record has been deleted"
@app.route('/list')
def list():
response = ""
persons = Person.query.all()
for person in persons:
response += person.first_name + " " + person.last_name + " " + person.email + "<br>"
return response
if __name__ == '__main__':
app.run(debug=True)
Documentation
Install and update using pip:
pip install -U PF-Flask-DB
Please find the Documentation with example from hmtmcse.com
Donate
Problem Fighter develops and supports PF-Flask-DB and the libraries it uses. In order to grow the community of contributors and users, and allow the maintainers to devote more time to the projects.
Contributing
For guidance on setting up a development environment and how to make a contribution to PF-Flask-DB, see the contributing guidelines.
Links
- Changes : https://opensource.problemfighter.org/flask/pf-flask-db
- PyPI Releases : https://pypi.org/project/pf-flask-db
- Source Code : https://github.com/problemfighter/pf-flask-db
- Issue Tracker : https://github.com/problemfighter/pf-flask-db/issues
- Website : https://www.problemfighter.com/open-source
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file PF-Flask-DB-1.0.1.tar.gz
.
File metadata
- Download URL: PF-Flask-DB-1.0.1.tar.gz
- Upload date:
- Size: 9.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 22a73fb495e3a13f5d7fc9b5e4d238a05edbc360351e54969ad4fa3f64297815 |
|
MD5 | 9b2732b452576a76506f8c0e9dada2fb |
|
BLAKE2b-256 | 145483b5edef208b8a3e032878551058cee9f138d69f4b9dec71a97022a2d52b |
File details
Details for the file PF_Flask_DB-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: PF_Flask_DB-1.0.1-py3-none-any.whl
- Upload date:
- Size: 14.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 43c8473d5aa7cde2254d77a8bbc3035bf571eb01e69cd0672af75c75902ec1a6 |
|
MD5 | d4f8f41d09d95df23573cd9cb20f54b3 |
|
BLAKE2b-256 | a7d0e63037163a6673a06fc1156ba40450e2419292e79d50d36b209695111a21 |