{
"id": "fn-sqlite-open",
"dataComponent": "sqlite",
"heading": {
"title": "open",
"badges": ["SQLite"]
},
"synopsis": "Opens a SQLite database file and returns a handle used for subsequent queries and operations.",
"codeBlocks": [
"extend(\"sqlite\")\n\n# Open a database file (creates if not present):\nres = sqlite:open([ path: \"test.db\" ])\nsput(res)\n# => [ handle:1000 ]\n\n# With custom open flags:\nres = sqlite:open([ path: \"test.db\", flags: \"ro\" ])\n# flags: \"ro\" (read-only), \"rw\" (read-write), \"rwc\" (read-write/create)"
],
"notes": [
"Takes a single keyed array as argument, e.g., [ path: \"dbfile.sqlite\", flags: \"rwc\" ].",
"Supported flags: \"ro\" (read-only), \"rw\" (read/write), \"rwc\" (read/write/create; default).",
"Returns a keyed array: [ handle:int ] which is used in later calls to sqlite:query and sqlite:close.",
"Handles are unique for the lifetime of your session. Opening the same path multiple times yields different handles.",
"If the file cannot be opened (bad path, permissions), an error is raised."
]
}