Python Firebase 模块2024年8月29日 | 23 分钟阅读 Firebase 是 Python 提供的一个库,用于使用 Firebase 提供的各种服务。为了更好地理解 Firebase 库,我们首先需要了解 Firebase 本身以及它提供的不同服务。Google 的 Firebase 技术允许开发者创建移动和 Web 应用程序。它最初是一家独立公司,成立于 2011 年。Google 于 2014 年收购了该平台,现在它是 Google 应用开发的主要产品。 你可能知道,Firebase 是 Google 用于加速应用开发的工具。它提供 BaaS,即后端即服务,这意味着 Firebase 会处理云基础设施和所有后端需求。这让你能更快地设计和部署应用。实时数据库、Cloud Firestore 和身份验证只是 Firebase 众多强大功能中的一部分。它还支持托管,并为机器学习任务(如文字识别、图片标记等)提供 API!Firebase 是一套工具,可让你“构建、改进和发展你的应用”,它提供的工具涵盖了许多开发者通常需要自己构建但又不想构建的服务,因为他们更愿意专注于应用体验。这包括分析、身份验证、数据库、配置、文件存储、推送消息等。这些服务基于云,并且几乎不需要开发者付出任何努力即可扩展。 当我说“托管在云端”时,我指的是 Google 的后端组件,它们完全由 Google 维护和管理。Firebase 的客户端 SDK 直接与这些后端服务交互,从而消除了你的应用和服务之间的任何中间件需求。如果你正在使用 Firebase 的数据库选项之一,你通常会在客户端应用中编写代码来查询数据库。然而,传统的应用开发通常涉及编写前端和后端代码。前端代码只调用后端提供的 API 端点,由后端代码处理繁重的工作。而使用 Firebase 产品,则绕过了传统的后端,将工作重心放在了客户端。Firebase 控制台为每个产品提供了管理访问权限。 在这些 SDK 之上,还有一个名为 FirebaseUI (Android, iOS, web) 的库,它包含许多有用的工具,使 Firebase 编程变得更加容易。还有一些额外的项目,它们封装了用于 Angular 的 Web SDK,例如 AngularFire。这些都是免费使用的。Firebase 是开源的坚定支持者。 Firebase 允许开发者专注于创造卓越的用户体验。你不需要管理任何服务器,也不需要编写 API。Firebase 就是你的服务器、API 和数据存储,它的设计方式允许你根据特定需求进行定制。是的,对于复杂的应用程序,你偶尔需要利用 Google Cloud 的其他部分。Firebase 不可能对每个人都做到尽善尽美,但它已经非常接近了。 现在,让我们来看一下 Firebase 套件提供的不同服务或产品,所有这些服务或产品都是 Google 提供的 Firebase 套件的一部分。各种服务如下:
代码输出 These are the possibilities given below; choose any one of them.:: 1. To establish a connection to the Firebase Database using the Firebase module of python. 2. To write data to the Firebase Database using the Firebase module of python. 3. To read data from the Firebase Database using the Firebase module of python. 4. To delete data from the Firebase Database using the Firebase module of python. 5. To update a data/record in the Firebase Database using the Firebase module of python. 6. To terminate the code and stop the choices from being displayed. 1 Enter the Firebase Database Access link:: https://xxxxxx-yyyyy.firebaseio.com A connection to the Database was established successfully. To continue with code execution, type [y] otherwise [n]. y These are the possibilities given below; choose any one of them.:: 1. To establish a connection to the Firebase Database using the Firebase module of python. 2. To write data to the Firebase Database using the Firebase module of python. 3. To read data from the Firebase Database using the Firebase module of python. 4. To delete data from the Firebase Database using the Firebase module of python. 5. To update a data/record in the Firebase Database using the Firebase module of python. 6. To terminate the code and stop the choices from being displayed. 2 Enter the data you want to add to the Firebase Database:: Enter the name of the student: Nirnay Enter the roll no of the student: 35 Enter the marks of the student: 92 {'student_marks': '92', 'student_name': 'Nirnay', 'student_rollno': '35'} Data added sucessfully to the Firebase Database. To continue with code execution, type [y] otherwise [n]. y These are the possibilities given below; choose any one of them.:: 1. To establish a connection to the Firebase Database using the Firebase module of python. 2. To write data to the Firebase Database using the Firebase module of python. 3. To read data from the Firebase Database using the Firebase module of python. 4. To delete data from the Firebase Database using the Firebase module of python. 5. To update a data/record in the Firebase Database using the Firebase module of python. 6. To terminate the code and stop the choices from being displayed. 2 Enter the data you want to add to the Firebase Database:: Enter the name of the student: Rahul Enter the roll no of the student: 21 Enter the marks of the student: 97 {'student_marks': '97', 'student_name': 'Rahul', 'student_rollno': '21'} Data added sucessfully to the Firebase Database. To continue with code execution, type [y] otherwise [n]. y These are the possibilities given below; choose any one of them.:: 1. To establish a connection to the Firebase Database using the Firebase module of python. 2. To write data to the Firebase Database using the Firebase module of python. 3. To read data from the Firebase Database using the Firebase module of python. 4. To delete data from the Firebase Database using the Firebase module of python. 5. To update a data/record in the Firebase Database using the Firebase module of python. 6. To terminate the code and stop the choices from being displayed. 2 Enter the data you want to add to the Firebase Database:: Enter the name of the student: Priyanka Enter the roll no of the student: 15 Enter the marks of the student: 89 {'student_marks': '89', 'student_name': 'Priyanka', 'student_rollno': '15'} Data added sucessfully to the Firebase Database. To continue with code execution, type [y] otherwise [n]. y These are the possibilities given below; choose any one of them.:: 1. To establish a connection to the Firebase Database using the Firebase module of python. 2. To write data to the Firebase Database using the Firebase module of python. 3. To read data from the Firebase Database using the Firebase module of python. 4. To delete data from the Firebase Database using the Firebase module of python. 5. To update a data/record in the Firebase Database using the Firebase module of python. 6. To terminate the code and stop the choices from being displayed. 3 Data present in the Firebase Database:: '8e606c6eca3711ec' : {'student_marks': '92', 'student_name': 'Nirnay', 'student_rollno': '35'} '8e606c6eca3711fr' : {'student_marks': '97', 'student_name': 'Rahul', 'student_rollno': '21'} '8e606c6eca3712gq' : {'student_marks': '89', 'student_name': 'Priyanka', 'student_rollno': '15'} To continue with code execution, type [y] otherwise [n]. y These are the possibilities given below; choose any one of them.:: 1. To establish a connection to the Firebase Database using the Firebase module of python. 2. To write data to the Firebase Database using the Firebase module of python. 3. To read data from the Firebase Database using the Firebase module of python. 4. To delete data from the Firebase Database using the Firebase module of python. 5. To update a data/record in the Firebase Database using the Firebase module of python. 6. To terminate the code and stop the choices from being displayed. 5 Enter the ID of the record that you want to update in the Firebase Database:: 8e606c6eca3711fr Enter the what parameter of the record you want to update? student_marks Enter the new value of the student_marks, you want to update? 96 Record updated successfully from the Firebase Database. To continue with code execution, type [y] otherwise [n]. y These are the possibilities given below; choose any one of them.:: 1. To establish a connection to the Firebase Database using the Firebase module of python. 2. To write data to the Firebase Database using the Firebase module of python. 3. To read data from the Firebase Database using the Firebase module of python. 4. To delete data from the Firebase Database using the Firebase module of python. 5. To update a data/record in the Firebase Database using the Firebase module of python. 6. To terminate the code and stop the choices from being displayed. 3 Data present in the Firebase Database:: '8e606c6eca3711ec' : {'student_marks': '92', 'student_name': 'Nirnay', 'student_rollno': '35'} '8e606c6eca3711fr' : {'student_marks': '96', 'student_name': 'Rahul', 'student_rollno': '21'} '8e606c6eca3712gq' : {'student_marks': '89', 'student_name': 'Priyanka', 'student_rollno': '15'} To continue with code execution, type [y] otherwise [n]. y These are the possibilities given below; choose any one of them.:: 1. To establish a connection to the Firebase Database using the Firebase module of python. 2. To write data to the Firebase Database using the Firebase module of python. 3. To read data from the Firebase Database using the Firebase module of python. 4. To delete data from the Firebase Database using the Firebase module of python. 5. To update a data/record in the Firebase Database using the Firebase module of python. 6. To terminate the code and stop the choices from being displayed. 4 Enter the ID of the record that you want to delete from the Firebase Database:: 8e606c6eca3712gq Record deleted successfully from the Firebase Database. To continue with code execution, type [y] otherwise [n]. y These are the possibilities given below; choose any one of them.:: 1. To establish a connection to the Firebase Database using the Firebase module of python. 2. To write data to the Firebase Database using the Firebase module of python. 3. To read data from the Firebase Database using the Firebase module of python. 4. To delete data from the Firebase Database using the Firebase module of python. 5. To update a data/record in the Firebase Database using the Firebase module of python. 6. To terminate the code and stop the choices from being displayed. 3 Data present in the Firebase Database:: '8e606c6eca3711ec' : {'student_marks': '92', 'student_name': 'Nirnay', 'student_rollno': '35'} '8e606c6eca3711fr' : {'student_marks': '96', 'student_name': 'Rahul', 'student_rollno': '21'} To continue with code execution, type [y] otherwise [n]. y These are the possibilities given below; choose any one of them.:: 1. To establish a connection to the Firebase Database using the Firebase module of python. 2. To write data to the Firebase Database using the Firebase module of python. 3. To read data from the Firebase Database using the Firebase module of python. 4. To delete data from the Firebase Database using the Firebase module of python. 5. To update a data/record in the Firebase Database using the Firebase module of python. 6. To terminate the code and stop the choices from being displayed. 6 说明 在上面编写的代码中,解释了 Firebase 模块不同函数的用法。在这段代码中,我们借助 Python 的 Firebase 库,在 Firebase 云中创建了一个数据库。代码中执行了各种操作,这些操作包括连接到 Firebase 云数据库,成功连接后,下一步是从用户那里获取输入数据并将其转换为 Python 字典对象,然后将该字典对象写入 Firebase 云数据库,接着读取存储在 Firebase 云数据库中的所有数据。除了读写,我们还可以从 Firebase 云数据库中删除已有的记录,也可以更新已有的记录。然后,编写了 main 函数,用于创建上述类的对象,通过这个创建的对象,我们可以调用该类中编写的各种方法,每个方法都描述了 Firebase 云数据库的特定功能。Firebase 云数据库支持的不同选项或操作包括:在云数据库中创建新记录、从云数据库中删除已有的记录、读取并显示存储在该特定数据库中的所有记录,以及更新 Firebase 云数据库中已存在记录的特定参数。对于所有这些功能,Firebase 的 Python 库都提供了不同的函数,并且我们在上面编写的类中为所有这些功能编写了不同的函数,以便更好地理解它们。 Firebase 在开发者中如此受欢迎是有原因的,其受欢迎的主要原因在于它为开发者提供了大量的优势,帮助他们节省时间,这些时间可以投入到其他任务中,而不是一次又一次地重复造轮子。现在,让我们快速浏览一下 Firebase 库的一些主要优势。
Firebase 的缺点
因此,在本文中,我们了解了 Python 中 Firebase 模块的用法。 下一个主题儿童 Python 编程 |
我们请求您订阅我们的新闻通讯以获取最新更新。