I added i way that doesn't execute query CREATE TABLE because it could affect performance.
Reasons
Minimal Query Overhead: The table_exists function runs a simple query against the sqlite_master table, which is a lightweight operation.
Avoiding Unnecessary Execution: The CREATE TABLE IF NOT EXISTS statement, while optimized, still involves parsing and some level of execution planning by SQLite.
Pros: Explicit checks, avoids unnecessary parsing and execution planning.
Cons: Slight overhead of additional query per table.
TODOS
Still the code isn't perfect, we need to implement a way to handle possible errors from database and avoid app to crash.
I added i way that doesn't execute query CREATE TABLE because it could affect performance.
Reasons
Minimal Query Overhead: The table_exists function runs a simple query against the sqlite_master table, which is a lightweight operation.
Avoiding Unnecessary Execution: The CREATE TABLE IF NOT EXISTS statement, while optimized, still involves parsing and some level of execution planning by SQLite.
Pros: Explicit checks, avoids unnecessary parsing and execution planning.
Cons: Slight overhead of additional query per table.
TODOS
Still the code isn't perfect, we need to implement a way to handle possible errors from database and avoid app to crash.