Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,195,087 members, 7,957,071 topics. Date: Tuesday, 24 September 2024 at 06:25 AM |
Nairaland Forum / Bamido's Profile / Bamido's Posts
(1) (of 1 pages)
Programming / Building A Python Flask Application With Database Modelling And Design by bamido: 1:24am On Apr 09 |
In the realm of web development, building applications that are scalable, secure, and maintainable is crucial. One key aspect of achieving this is through effective database modelling and design. In this article, we'll explore how to design a relational database schema for a Role-Based Access Control (RBAC) system using Python Flask, SQLAlchemy, and Flask-Migrate. Step 1: Entity Relationship with attributes Before diving into coding, it's essential to understand the entities and their relationships within the system. Here are the entities identified for our RBAC system along with their attributes: - Roles: role_id, role_name, created_at, updated_at - Users: user_id, role_id(fk), username, email_address, password, lastname, firstname, phonenumber, dateofbirth, created_at, updated_at - Modules: module_id, module_title, module_order, module_icon, created_at, updated_at - Tasks: task_id, module_id(fk), task_label, task_url, task_route, task_method, task-icon, isdashboard, isnavbar, created_at, updated_at - Privileges: privilege_id, task_id(fk), role_id(fk), created_at, updated_at Step 2: SQLAlchemy Models To interact with the database, we'll use SQLAlchemy, a powerful SQL toolkit and Object-Relational Mapping (ORM) library for Python. Here's how to set up SQLAlchemy: ```python # Install SQLAlchemy pip install Flask SQLAlchemy ``` Set up the database configuration in `flaskenv.py`: ```python DATABASE_URI='mysql://root:root@localhost/python_rbac_db?unix_socket=/Applications/MAMP/tmp/mysql/mysql.sock' ``` Connect to the MySQL database in `config.py`: ```python SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URI') ``` Create `mydb.py` and import SQLAlchemy: ```python from flask_sqlalchemy import SQLAlchemy db = SQLAlchemy() ``` Step 3: Create Models Based on the identified RBAC entities and attributes, we'll create SQLAlchemy models. For instance: ```python from mydb import db class RoleModel(db.Model): __tablename__ = 'roles' role_id = db.Column(db.Integer, primary_key=True) role_name = db.Column(db.String(50), nullable=False) created_at = db.Column(db.DateTime, nullable=False) updated_at = db.Column(db.DateTime, nullable=False) # Define relationships with other tables if needed class UserModel(db.Model): __tablename__ = 'users' user_id = db.Column(db.Integer, primary_key=True) # Define other columns ``` Update `__init__.py` for Database Migrations: ```python from mydb import db from flask_migrate import Migrate migrate = Migrate() migrate.init_app(app, db) ``` Step 4: Database Migrations Database migrations are essential for managing changes to the database schema over time. We'll use Flask-Migrate, which is a Flask wrapper for Alembic. Install Flask-Migrate and mysqlclient: ```bash pip install flask-migrate pip install mysqlclient ``` Create Migration Repository: ```bash flask db init ``` Generate Migration Files: ```bash flask db migrate ``` Run Migration: ```bash flask db upgrade ``` By following these steps, we've successfully designed our database schema for the RBAC system using Python Flask, SQLAlchemy, and Flask-Migrate. This ensures that our application remains flexible and maintainable as it evolves over time. In the next stages of development, we can focus on implementing business logic, authentication, authorization, and other functionalities to complete our RBAC system. Building robust applications requires attention to detail, especially in areas like database modelling and design. With the tools and techniques outlined in this article, developers can create scalable and secure web applications with ease. Source Code on GitHub Click here to read more and download the source code. https://academy.strideshub.com/blogdetails/day-4-building-a-python-flask-application-with-database-modelling-and-design/Nw==
|
Politics / I'll Go And Talk To The President by bamido: 9:09am On Feb 18, 2021 |
I'll Go And Talk To The President I'll go to the president and tell him about the people's plight, I'll go to the president and tell him about the ambushed and killing of farmers, I'll go to the president and talk to him about the herdsmen and their settlement, I'll go to the president and remind him about his unfulfilled promises, I'll go to the president and tell him about the masses hardship, agony, anguished and plea. I'll go to the president and remind him about the enormous natural resources the country is blessed with, I'll go to the politicians and remind them of yesterday promises not tomorrow's election, I'll go to the house of representatives to remind them of people's plea to represent them well.. I'll go to the house of corrupt leaders and tell them about the Messiah who gives them power to govern in truth not to be the ambassadors of corruption.. I'll go to the universe and beyond and tell all about the greed of men in Power, I'll go to the president and tell him about the high rate of unemployment, crimes, segregation, tribalism, favouritism, religious differences, nepotism, regionalism and people's clamour for change.. I'll go and tell him these and more.. By Ezra Bature https://naijapoetry.com/Home/Poem?poemid=684#tagpoem_684 |
Literature / Letter To My Son by bamido: 9:48am On Mar 19, 2019 |
Tomorrow when you see me no more And you’re left to man your world alone, When pecks and hugs and all the warmth of my skin Had grown wings; Don’t fret my son, That’s how it should be. And peradventure During the course of your sojourning, You found love, Choose carefully, For all bright and beautiful ain’t exact way they look Our world is a mirage. Smile my boy! So you’ll live long Wave and greet the man that crosses your path, For whom you met on your way up, May hold the ladder for you to descend, That’s how it should be. You’ll meet wolves, in sheep skin, Human of varying shapes, Wonder, ponder and beat your emotion tenderly For that’s just the way we are, That’s the cruel world we live. See son, don’t be wary during adversities, For the earth is a pendulum, To and fro it goes, It waddles and toddles. All you’ve got is believe in yourself That’s how it should be. I’m leaving you some gift to give to your own son, Just like my father sent me to you, I’m giving you some books, Read and pass on to your generation. Go! Be an eagle Go! Be a man! For that’s just how it should be. Author: Bayo Akinnola. Poem: [http://naijapoetry.com/Home/Poem?poemid=163] For more poems visit [http://naijapoetry.com]
|
Literature / The Benefits Of Naija Poetry (www.naijapoetry.com) by bamido: 10:18pm On Mar 11, 2018 |
The Benefits of Naija Poetry (www.naijapoetry.com) Introduction: Naija Poetry is an educational platform that promotes individual talented poets. The website adddress is www.naijapoetry.com and the Naija Poetry Android App can be downloaded from the Google Play Store (https://play.google.com/store/apps/details?id=com.naijapoetry.app) 1. Poet can particpate in free poetry competition to win fabulous prize. The Fortnight Poetry Game (FPG) is a form of Haiku poem consists of three lines, with the first and last line of a Haiku have 5 syllables and the middle line has 7 sylabbles. Particpant are expected to submit a poem based on the FPG image posted; and winners emerge on the last friday of the second week. 2. Collaboration with other poets. 3. Information on Poem Publishing. 4. It encourages, promotes and help Poets/People to maximize their potential. 5. It's a community of poets with a lot of upcoming features. 6. Poets can particpate in Quarterly Poetry Competition (QPC) and lots more. 7. You earn credit for posting poems. The credit can be used to particpate in QPC and other upcoming features. Hence, get register now and post yout first poem. http://naijapoetry.com See you on Naija Poetry!
|
Poems For Review / Naija Poetry by bamido: 11:42am On Jan 31, 2018 |
https://play.google.com/store/apps/details?id=com.naijapoetry.app Naija Poetry is an education platform where individual talented poet can post poems, share poems and participate in poetry competition. It features Fortnight poetry game, Quarterly poetry competition. The platform is free to join. Some of the poems posted on the platform are listed below: 1. Bring Back Our Girls 2. Throwback Thursday For more poems visit www.naijapoetry.com
|
Software/Programmer Market / Re: School Management Software! Anybody? by bamido: 12:12pm On Jul 11, 2009 |
School Management Software, University Portal, College Portal. Contact africpoet@yahoo.com |
(1) (of 1 pages)
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 30 |