Unity3D connects SQLite as the basic function of the database [detailed graphic tutorial]

1. Briefly introduce the advantages of SQLite (from ChatGPT)

  1. Lightweight: SQLite is an embedded database engine. Its library file is very small and has no independent server process. It is suitable for embedding into other applications and is very suitable for lightweight projects or mobile applications.
  2. Zero configuration: Using SQLite does not require complex configuration or management. You only need to simply create a file to start using it, reducing additional operation and maintenance costs.
  3. Single user: SQLite is single-user and can only support one write connection, but multiple read connections are possible, which is suitable for single-user or low-concurrency scenarios.
  4. Efficient: SQLite is known for its atomic operations, built-in transaction support and crash recovery capabilities, and has good performance for applications with frequent reads and relatively few writes.

2. SQLite installation and basic use

1. SQLite official website address  SQLite Download Page

If you can't log in, download the package I downloaded.


Link: https://pan.baidu.com/s/16nDJ6AMbTaJzIWkgW-7YjA 
Extraction code: 9oiu 

(1) Just find your corresponding version and download it.

(2) You can choose the download storage address, that’s all

(3) Double-click to open sqlite3.exe , then the installation is successful.

(4) Create a table through the .open bbb.db command and find that bbb.db is generated in the folder

(5) Create table:  create table users(id int,name text);

(6) Insert data: insert into users(id,name) values(1,'aaa');    // Note the use of single quotes here

                           insert into users(id,name) values(2,'aba');

(7) Query all data: select * from users; 

You can see that the two data we just inserted are printed out.


3. Installation and basic use of the visualization tool SQLiteStudio

       It is obviously not appropriate to adjust the data through operation commands, so you can choose a SQL visualization tool at this time. Here I use SQLiteStudio

 1. Official website download link: SQLiteStudio

If you can't log in, download the package I downloaded.


Link: https://pan.baidu.com/s/1-K8Z3obkUYBwj_68X_LXxA 
Extraction code: lehd 

2. Ctrl+O opens the library bbb.db  we just created.

 3. This way we can visually see the data we just inserted.

4. Establish contact with Unity

1. First, you need to find the file Mono.Data.Sqlite.dll provided by Unity and find the corresponding version.

What I am using here is 2021.3.10.

 2. Copy Mono.Data.Sqlite.dll,  System.Data.dll and sqlite3 to Unity ’s Plugins

 (To be continued)

Guess you like

Origin blog.csdn.net/weixin_46711336/article/details/132600300