Automatically translated.View original post

Light database sqlite3

# Trending # Web Site Writing Basics

# Lemon 8 Howtoo # Drug sign with lemon8 # lemon 8 diary

🗄️ is SQLite3?

SQLite3 is a Relational Database Management System - RDBMS that is very special and popular because it is an Embedded or Serverless database.

Definition: SQLite is not a standalone application that requires a separate server (like MySQL or PostgreSQL) to be installed, but a library (library) embedded directly into the application itself.

Storage format: All databases (tables, data, indexes) are stored in a single file, on the user's disk (typically a file with a extension such as .db or .sqlite).

In other words, SQLite is the most widely used database engine in the world because it is embedded in many software and devices such as web browsers (Firefox, Chrome), mobile operating systems (Android, iOS), and small desktop software.

👍 The main advantages of SQLite3

SQLite has several advantages that make it suitable for specialized applications:

1. ⚙️ No server required (Serverless)

Ease: No Server Process required to run behind the scenes. No installation, setup, or maintenance of complex servers.

Connection: Connecting to a database is simple, just open and read the database file directly.

2. 💨 Lightweight & Fast (Lightweight & Fast)

Small: The library itself is very small (about 500 KB to 1 MB), making it ideal for embedding in devices with limited resources such as mobile, IoT, and embedded systems.

Performance: For data reading (Read Operation) is usually faster than server-based databases in low to moderate use environments.

3. 💾 Easy storage

Single file: All data is included in a single file, making it easy to store, copy, move, or back up (just Copy files).

Cross-Platform: Database files can be instantly copied to use on different operating systems (e.g. built on Linux and then opened on Windows).

4. 🔬 Suitable for Development & Testing

Developers often use SQLite as a database for Local Development (local development) and Unit Tests runs because it's easy to install and quick to get started.

5. 🛡️ ACID support (Transaction Compliance)

Even though it is a small database, SQLite still supports ACID (Atomicity, Consistency, Isolation, Durability) features, ensuring that transactions (Transactions) are accurate and reliable.

2025/11/28 Edited to

... Read moreถ้าเพิ่งเริ่มทำเว็บ/แอปแล้วเจอคำว่า “SQLite” บ่อย ๆ ฉันเคยงงเหมือนกันว่า sqlite คืออะไร แล้วต่างจาก MySQL/PostgreSQL ยังไง สรุปที่เข้าใจง่ายที่สุดคือ SQLite เป็นฐานข้อมูลเชิงสัมพันธ์ที่ “อยู่เป็นไฟล์เดียว” และ “ไม่ต้องมีเซิร์ฟเวอร์” แยกให้ปวดหัว เวลาใช้งานก็เหมือนเราเปิดไฟล์ .db / .sqlite แล้วสั่ง SQL คุยกับมันได้เลย สิ่งที่ฉันชอบมากคือมันเหมาะกับงานเริ่มต้นและงานทดลองสุด ๆ เช่น ทำโปรเจกต์เล็ก ๆ, ทำระบบเก็บข้อมูลในเครื่อง (local), หรือทำแอปมือถือที่อยากมีฐานข้อมูลติดไปกับแอป พอเราแพ็กโปรเจกต์ไปไหนก็แค่พกไฟล์ฐานข้อมูลไฟล์เดียว จบ ตัวอย่างการใช้งานที่เจอบ่อย (อิงจากที่หลายคนทำจริง) - แอปมือถือ: เก็บข้อมูลออฟไลน์ เช่น รายการสินค้า/บันทึก/ประวัติการใช้งาน แล้วค่อยซิงก์ทีหลัง - งานทดสอบ/พัฒนาในเครื่อง: ใช้แทนฐานข้อมูลจริงตอน dev เพราะตั้งค่าง่าย เปิดปุ๊บใช้ได้ปั๊บ - โปรแกรมเดสก์ท็อปเล็ก ๆ: เช่น โปรแกรมจัดการ “ตารางสินค้า (products)” เก็บรหัส ชื่อ ราคา รายละเอียด ที่อยู่รูปภาพไว้ในไฟล์เดียว ถ้าถามว่าเริ่มใช้ SQLite ต้องมีเครื่องมืออะไรบ้าง ฉันมักเริ่มจาก 2 แบบนี้ 1) ใช้คำสั่งในเทอร์มินัล: ติดตั้ง sqlite3 แล้วสั่งสร้างไฟล์ฐานข้อมูล จากนั้น CREATE TABLE/INSERT/SELECT ได้เลย 2) ใช้โปรแกรม GUI: อย่าง Browser for SQLite จะเห็นตารางชัดมาก เหมาะกับคนอยากคลิกดูข้อมูลในตาราง เช่น products ดูคอลัมน์รหัสสินค้า ชื่อ ราคา รายละเอียด และ path รูปภาพ แก้ไขได้สะดวก ข้อควรรู้ก่อนเลือกใช้ (อันนี้ช่วยตัดสินใจได้ดี) - SQLite เหมาะกับงานผู้ใช้ไม่เยอะมากหรือไม่ได้เขียนพร้อมกันหนัก ๆ เพราะมันล็อกไฟล์เวลามีการเขียน ถ้ามีการเขียนพร้อมกันจำนวนมากอาจช้ากว่าฐานข้อมูลแบบเซิร์ฟเวอร์ - แต่ถ้าเน้นอ่านเยอะ ๆ (read-heavy) หรือเก็บข้อมูลในเครื่อง/ต้นแบบโปรเจกต์ SQLite ตอบโจทย์มาก สรุปมุมมองของฉัน: ถ้าคุณกำลังหาฐานข้อมูลที่ “เริ่มง่าย เบา ไฟล์เดียว ไม่ต้องตั้งเซิร์ฟเวอร์” และยังใช้ SQL แบบ relational ได้เต็ม ๆ SQLite3 คือหนึ่งในตัวเลือกที่คุ้มและเป็นมิตรกับมือใหม่สุด ๆ