Can anybody say how to create database in run-time using ZEOS?
I'm need:
1. Create database
2. Set PRAGMAs
3. Create tables
If not exists DB file, then it will be created. I know about that. But PRAGMAs don't set.
I trying do it using code:
Code: Select all
var
ss: TStringList;
begin
ss := TStringList.Create;
ss.Add('PRAGMA auto_vacuum=full');
ss.Add('PRAGMA automatic_index=on');
ss.Add('PRAGMA busy_timeout=4000');
ss.Add('PRAGMA cache_size=2000;');
ss.Add('PRAGMA case_sensitive_like=off;');
ss.Add('PRAGMA checkpoint_fullfsync=off;');
ss.Add('PRAGMA collation_list="NOCASE", "RTRIM", "BINARY";');
ss.Add('PRAGMA compile_options="ENABLE_COLUMN_METADATA", "ENABLE_FTS3", "ENABLE_FTS3_PARENTHESIS", "ENABLE_RTREE", "SOUNDEX", "SYSTEM_MALLOC", "THREADSAFE=1";');
ss.Add('PRAGMA encoding=UTF-8;');
ss.Add('PRAGMA foreign_keys=on;');
ss.Add('PRAGMA freelist_count=0;');
ss.Add('PRAGMA fullfsync=off;');
ss.Add('PRAGMA ignore_check_constraints=off;');
ss.Add('PRAGMA journal_mode=delete;');
ss.Add('PRAGMA journal_size_limit=-1;');
ss.Add('PRAGMA legacy_file_format=off;');
ss.Add('PRAGMA locking_mode=normal;');
ss.Add('PRAGMA max_page_count=1073741823;');
ss.Add('PRAGMA mmap_size=0;');
ss.Add('PRAGMA page_count=8;');
ss.Add('PRAGMA page_size=4096;');
ss.Add('PRAGMA parser_trace=;');
ss.Add('PRAGMA read_uncommitted=off;');
ss.Add('PRAGMA recursive_triggers=off;');
ss.Add('PRAGMA reverse_unordered_selects=off;');
ss.Add('PRAGMA schema_version=128;');
ss.Add('PRAGMA secure_delete=off;');
ss.Add('PRAGMA synchronous=full;');
ss.Add('PRAGMA temp_store=default;');
ss.Add('PRAGMA user_version=0;');
ss.Add('PRAGMA vdbe_addoptrace=;');
ss.Add('PRAGMA vdbe_listing=;');
ss.Add('PRAGMA vdbe_trace=;');
ss.Add('PRAGMA wal_autocheckpoint=1000;');
ss.Add('PRAGMA writable_schema=on;');
ss.Add('CREATE TABLE "dbinfo" (');
ss.Add(' "groupsCount" INTEGER,');
ss.Add(' "linksCount" INTEGER,');
ss.Add(' "treeDepth" INTEGER,');
ss.Add(' "imagesCount" INTEGER,');
ss.Add(' "major_ver" SMALLINT,');
ss.Add(' "minor_ver" SMALLINT,');
ss.Add(' "TimeCreate" TIME,');
ss.Add(' "DateCreate" DATE,');
ss.Add(' "LastAccess" DATETIME,');
ss.Add(' "UID" TEXT,');
ss.Add(' "name" TEXT,');
ss.Add(' "desc" TEXT);');
ZConnection1.Connect;
if ZConnection1.ExecuteDirect(ss.Text) then
ShowMessage('ok')
else
ShowMessage('fail');
end;
Why that?