- Dart:Scalable Application Development
- Davy Mitchell Sergey Akopkokhyants Ivo Balbaert
- 449字
- 2021-07-09 18:56:26
Saving to the database
The data collector application currently writes to the filesystem. While this is useful for archiving, it makes it difficult and slow to access and query any sort of analysis or display.
Note
If you are not experienced with databases, here is a very rapid introduction! Databases are collections of data in a structured form. These are accessed and managed via a database management system. You may have heard of SQL Server, MySQL, Hadoop or Oracle.
Databases are typically accessed using a language called SQL to read and write records from the database. Data is usually organized into tables, and each table is made up of records. Each table has a set columns defined as data types—it is similar to variables in a programming language. SQL is strong on sorting, grouping, and working with sets of data.
SQL can be stored in the database in a number of forms, with the most common being a stored procedure that can add/remove and update data, and perform some processing.
Connecting to a database almost always requires a login and may be on a remote computer. This is sometimes referred to as a connection string. It behaves much like a network connection.
Installing a database system
There are numerous database systems available and you probably already have your favorite one! For the purposes of this book, the database used will be PostgreSQL as it is free, open source, and available for all the major operating systems. Also it is one of the easiest databases to install, so we can spend more time writing Dart.
PostgreSQL is a powerful, open-source, object-relational database system with a 15-year heritage behind it.
It is a first-class product and is used by big names in industry and government, such as Yahoo and the United Nations. It complies strongly with SQL language standards and can cope with database tables up to a maximum size of 32 terabytes.
PostgreSQL can be downloaded from http://www.postgresql.org/ for Mac, Linux, and Windows, and is available via most Linux distribution package managers. Also on the PostgreSQL download page, there are numerous virtual machine images available that just need to be downloaded and turned on.
The examples for this book assume that the database installation is the same machine that the software is run from. Adjusting the connection string will allow connection to remote machines.
Using PostgreSQL from Dart
The package postgresql
provides a very capable PostgreSQL database driver to use from the Dart program. It is a third-party package that is well regarded, and has had contributions from the Dart team.
The project for this section is called QuakeMonitorDB
and the fetching is identical to the filesystem version.
- SQL for Data Analytics
- 我的第一本算法書
- Access 2010數據庫基礎與應用項目式教程(第3版)
- 快速念咒:MySQL入門指南與進階實戰
- Cocos2d-x學習筆記:完全掌握Lua API與游戲項目開發 (未來書庫)
- Visual C#通用范例開發金典
- Python全棧數據工程師養成攻略(視頻講解版)
- .NET 4.5 Parallel Extensions Cookbook
- 軟件工程基礎與實訓教程
- Java 從入門到項目實踐(超值版)
- 人件集:人性化的軟件開發
- Selenium自動化測試實戰:基于Python
- 區塊鏈原理、架構與應用(第2版)
- ROS Robotics Projects
- Mastering VMware Horizon 6