Python Firebase Course For Beginners

Python Firebase Course For Beginners

Welcome to Python Firebase Course for Beginners, in this Python Firebase Course for Beginners we are going to work with Firebase using Python Programming Language. especially we are going to work with Firebase Real Time Database, Firebase Authentication and Firebase Storage. and also we will use pyrebase library for this article, pyrebase is a simple python wrapper for the Firebase API. first of all you need to install pyrebase by using pip command like this.

Welcome to Python Firebase Course for Beginners, in this Python Firebase Course for Beginners we are going to work with Firebase using Python Programming Language. especially we are going to work with Firebase Real Time Database, Firebase Authentication and Firebase Storage. and also we will use pyrebase library for this article, pyrebase is a simple python wrapper for the Firebase API. first of all you need to install pyrebase by using pip command like this.

pip install pyrebase

pyrebase is for python3 and will not work in python2.

Check Python GUI Development With PyQt5

First of all you need to Create New Project in Firebase Console. and after that add pyrebase to your application.

for use with only user based authentication we can create the following configuration:

import pyrebase

config = {
  "apiKey": "apiKey",
  "authDomain": "projectId.firebaseapp.com",
  "databaseURL": "https://databaseName.firebaseio.com",
  "storageBucket": "projectId.appspot.com"
}

firebase = pyrebase.initialize_app(config)

A Pyrebase app can use multiple Firebase services.

firebase.auth() – Authentication

firebase.database() – Database

firebase.storage()– Storage

1: Firebase Authentication ?

Firebase Authentication provides backend services, easy-to-use SDKs, and ready-made UI libraries to authenticate users to your app. It supports authentication using passwords, phone numbers, popular federated identity providers like Google, Facebook and Twitter, and more.Firebase Authentication integrates tightly with other Firebase services, and it leverages industry standards like OAuth 2.0 and OpenID Connect, so it can be easily integrated with your custom backend.

The sign_in_with_email_and_password() method will return user data including a token you can use to adhere to security rules.

you can use this code for creating of users in your firebase console.

Make sure you have the Email/password provider enabled in your Firebase dashboard under Auth -> Sign In Method.


#create authetication
auth = firebase.auth()

#get the valid email and password from the user
email = input("Please Enter Your Email : ")
password = input("Please Enter Your Password : ")

#and authenticate the user 
user = auth.create_user_with_email_and_password(email, password)
print("User Created Successfully")

Also you can sign in with the created user .


signin = auth.sign_in_with_email_and_password(email, password)
print("Sign In Was Successfull")

Also you can do verification for the email using this code.


auth.send_email_verification(signin['idToken'])
print("Email Verification Has Been Sent")

Sending password reset emails


auth.send_password_reset_email(email)
print("We have sent an email, check your inbox ")

2: Firebase Real Time Database

The Firebase Realtime Database is a cloud-hosted database. Data is stored as JSON and synchronized in realtime to every connected client. When you build cross-platform apps or web applications , all of your clients share one Realtime Database instance and automatically receive updates with the newest data.

Note: before this make sure that you have enabled firebase real time database in your firebase console.

In here we are going to create firebase real time database, and after that we are going to save the data, to save data with a unique, auto-generated, timestamp-based key, use the push() method.

db = firebase.database()
data = {"name":"Parwiz Forogh"}

db.child("users").push(data)
print("Data added to real time database ")

To create your own keys use the set() method. The key in the example below is “OwnKey”.

db.child("users").child("OwnKey").set(data)

To update data for an existing entry use the update() method.


db.child("users").child("OwnKey").update({"name":"John Doe"})
print("Data updated successfully ")

db.child("users").child("-LzqIcMVMPaQKVLLjK5d").update({"name":"Updated Name"})
print("Data updated successfully ")

Queries return a PyreResponse object. Calling val() on these objects returns the query data.

Calling key() returns the key for the query data.

users = db.child("users").get()
print(users.val())

Each Returns a list of objects on each of which you can call val() and key().


all_users = db.child("users").get()

for users in all_users.each():
    print(users.val())
    print(users.key())

To delete data for an existing entry use the remove() method.


db.child("users").child("-LzqIcMVMPaQKVLLjK5d").remove()
print("User removed")

3: Firebase Storage

Cloud Storage for Firebase is a powerful, simple, and cost-effective object storage service built for Google scale. The Firebase SDKs for Cloud Storage add Google security to file uploads and downloads for your Firebase apps, regardless of network quality. You can use our SDKs to store images, audio, video, or other user-generated content. On the server, you can use Google Cloud Storage, to access the same files.

Note: make sure that you have enabled firebase storage in your firebase console.

First we create the storage object.

storage = firebase.storage()

Using child just like with the Database service, you can build paths to your data with the Storage service.

storage.child("images/newimage.jpg")

The put method takes the path to the local file and an optional user token.

storage.child("images/newimage.jpg").put("football.jpg")
print("Image Uploaded")

The download method takes the path to the saved database file and the name you want the downloaded file to have.

storage.child("images/newimage.jpg").download("downloaded.jgp")
print("Image Downloaded")

Thanks for reading .

Originally published by Parwiz at codeloop

Guide to Python Programming Language

Guide to Python Programming Language

Guide to Python Programming Language

Description
The course will lead you from beginning level to advance in Python Programming Language. You do not need any prior knowledge on Python or any programming language or even programming to join the course and become an expert on the topic.

The course is begin continuously developing by adding lectures regularly.

Please see the Promo and free sample video to get to know more.

Hope you will enjoy it.

Basic knowledge
An Enthusiast Mind
A Computer
Basic Knowledge To Use Computer
Internet Connection
What will you learn
Will Be Expert On Python Programming Language
Build Application On Python Programming Language

Python Programming Tutorials For Beginners

Python Programming Tutorials For Beginners

Python Programming Tutorials For Beginners

Description
Hello and welcome to brand new series of wiredwiki. In this series i will teach you guys all you need to know about python. This series is designed for beginners but that doesn't means that i will not talk about the advanced stuff as well.

As you may all know by now that my approach of teaching is very simple and straightforward.In this series i will be talking about the all the things you need to know to jump start you python programming skills. This series is designed for noobs who are totally new to programming, so if you don't know any thing about

programming than this is the way to go guys Here is the links to all the videos that i will upload in this whole series.

In this video i will talk about all the basic introduction you need to know about python, which python version to choose, how to install python, how to get around with the interface, how to code your first program. Than we will talk about operators, expressions, numbers, strings, boo leans, lists, dictionaries, tuples and than inputs in python. With

Lots of exercises and more fun stuff, let's get started.

Download free Exercise files.

Dropbox: https://bit.ly/2AW7FYF

Who is the target audience?

First time Python programmers
Students and Teachers
IT pros who want to learn to code
Aspiring data scientists who want to add Python to their tool arsenal
Basic knowledge
Students should be comfortable working in the PC or Mac operating system
What will you learn
know basic programming concept and skill
build 6 text-based application using python
be able to learn other programming languages
be able to build sophisticated system using python in the future

To know more:

Learn Python Programming

Learn Python Programming

Learn Python Programming

Description
Learn Python Programming

Learn Python Programming and increase your python programming skills with Coder Kovid.

Python is the highest growing programming language in this era. You can use Python to do everything like, web development, software development, cognitive development, machine learning, artificial intelligence, etc. You should learn python programming and increase your skills of programming.

In this course of learn python programming you don't need any prior programming knowledge. Every beginner can start with.

Basic knowledge
No prior knowledge needed to learn this course
What will you learn
Write Basic Syntax of Python Programming
Create Basic Real World Application
Program in a fluent manner
Get Familiar in Programming Environment