├── Include └── SQLite3 │ ├── Backup.mqh │ ├── Blob.mqh │ ├── Common.mqh │ ├── Defines.mqh │ ├── Imports.mqh │ ├── SQLite3.mqh │ ├── Statement.mqh │ └── Vfs.mqh ├── LICENSE ├── Library ├── MT4 │ └── sqlite3.dll └── MT5 │ └── sqlite3.dll ├── README.md └── Scripts └── Test └── TestSQLite3.mq4 /Include/SQLite3/Backup.mqh: -------------------------------------------------------------------------------- 1 | //+------------------------------------------------------------------+ 2 | //| Backup.mqh | 3 | //| Copyright 2017, Li Ding | 4 | //| dingmaotu@126.com | 5 | //+------------------------------------------------------------------+ 6 | #property strict 7 | 8 | #include "SQLite3.mqh" 9 | //+------------------------------------------------------------------+ 10 | //| Backup operation | 11 | //+------------------------------------------------------------------+ 12 | class Backup 13 | { 14 | private: 15 | intptr_t m_ref; 16 | public: 17 | Backup(const SQLite3 &dest,string destDbName,const SQLite3 &src,string srcDbName) 18 | { 19 | uchar destDbNameBuf[]; 20 | uchar srcDbNameBuf[]; 21 | StringToUtf8(destDbName,destDbNameBuf); 22 | StringToUtf8(srcDbName,srcDbNameBuf); 23 | m_ref=sqlite3_backup_init(dest.ref(),destDbNameBuf,src.ref(),srcDbNameBuf); 24 | } 25 | 26 | ~Backup() {sqlite3_backup_finish(m_ref);} 27 | bool isValid() const {return m_ref!=NULL;} 28 | intptr_t ref() const {return m_ref;} 29 | 30 | // SQLITE_OK | SQLITE_DONE for success completion 31 | // SQLITE_READONLY | SQLITE_IOERR_* | SQLITE_NOMEM is condidered fatal 32 | // SQLITE_BUSY if timeout waiting resource lock 33 | int step(int pages) {return sqlite3_backup_step(m_ref,pages);} 34 | int getPageCount() const {return sqlite3_backup_pagecount(m_ref);} 35 | int getRemaining() const {return sqlite3_backup_remaining(m_ref);} 36 | }; 37 | //+------------------------------------------------------------------+ 38 | -------------------------------------------------------------------------------- /Include/SQLite3/Blob.mqh: -------------------------------------------------------------------------------- 1 | //+------------------------------------------------------------------+ 2 | //| Blob.mqh | 3 | //| Copyright 2017, Li Ding | 4 | //| dingmaotu@126.com | 5 | //+------------------------------------------------------------------+ 6 | #property strict 7 | 8 | #include "SQLite3.mqh" 9 | //+------------------------------------------------------------------+ 10 | //| Blob for streaming IO | 11 | //+------------------------------------------------------------------+ 12 | class Blob 13 | { 14 | private: 15 | bool m_valid; 16 | intptr_t m_ref; 17 | public: 18 | Blob(const SQLite3 &conn,string db,string table,string column,long row,bool readonly=true) 19 | { 20 | char zDb[]; 21 | char zTable[]; 22 | char zColumn[]; 23 | StringToUtf8(db,zDb); 24 | StringToUtf8(table,zTable); 25 | StringToUtf8(column,zColumn); 26 | 27 | int res=sqlite3_blob_open(conn.ref(),zDb,zTable,zColumn,row,readonly?0:1,m_ref); 28 | m_valid=(res==SQLITE_OK); 29 | } 30 | ~Blob() {if(m_valid) sqlite3_blob_close(m_ref);} 31 | 32 | bool isValid() const {return m_valid;} 33 | intptr_t ref() const {return m_ref;} 34 | 35 | int size() const {return sqlite3_blob_bytes(m_ref); } 36 | 37 | int moveTo(long rowId) {return sqlite3_blob_reopen(m_ref,rowId);} 38 | int read(uchar &buf[],int size,int offset) {return sqlite3_blob_read(m_ref,buf,size,offset);} 39 | int write(const uchar &buf[],int size,int offset) {return sqlite3_blob_write(m_ref,buf,size,offset);} 40 | }; 41 | //+------------------------------------------------------------------+ 42 | -------------------------------------------------------------------------------- /Include/SQLite3/Common.mqh: -------------------------------------------------------------------------------- 1 | //+------------------------------------------------------------------+ 2 | //| Common.mqh | 3 | //| Copyright 2016-2017, Li Ding | 4 | //| dingmaotu@126.com | 5 | //+------------------------------------------------------------------+ 6 | #property strict 7 | 8 | // Assume MT5 is 64bit, which is the default. 9 | // Even though MT5 can be 32bit, there is no way to detect this 10 | // by using preprocessor macros. Instead, MetaQuotes provides a 11 | // function called IsX64 to detect this dynamically 12 | 13 | // This is just absurd. Why do you want to know the bitness of 14 | // the runtime? To define pointer related entities at compile time! 15 | // All integer types in MQL is uniform on both 32bit or 64bit 16 | // architectures, so it is almost useless to have a runtime function IsX64. 17 | 18 | // Why not a __X64__? 19 | #ifdef __MQL5__ 20 | #define __X64__ 21 | #endif 22 | 23 | #ifdef __X64__ 24 | #define intptr_t long 25 | #define uintptr_t ulong 26 | #define size_t long 27 | #else 28 | #define intptr_t int 29 | #define uintptr_t uint 30 | #define size_t int 31 | #endif 32 | 33 | #import "kernel32.dll" 34 | void RtlMoveMemory(intptr_t dest,const uchar &array[],size_t length); 35 | void RtlMoveMemory(uchar &array[],intptr_t src,size_t length); 36 | int lstrlen(intptr_t psz); 37 | int MultiByteToWideChar(uint codePage, 38 | uint flags, 39 | const intptr_t multiByteString, 40 | int lengthMultiByte, 41 | string &str, 42 | int length 43 | ); 44 | #import 45 | //+------------------------------------------------------------------+ 46 | //| Copy the memory contents pointed by src to array | 47 | //| array parameter should be initialized to the desired size | 48 | //+------------------------------------------------------------------+ 49 | void ArrayFromPointer(uchar &array[],intptr_t src,int count=WHOLE_ARRAY) 50 | { 51 | int size=(count==WHOLE_ARRAY)?ArraySize(array):count; 52 | RtlMoveMemory(array,src,(size_t)size); 53 | } 54 | //+------------------------------------------------------------------+ 55 | //| Copy array to the memory pointed by dest | 56 | //+------------------------------------------------------------------+ 57 | void ArrayToPointer(const uchar &array[],intptr_t dest,int count=WHOLE_ARRAY) 58 | { 59 | int size=(count==WHOLE_ARRAY)?ArraySize(array):count; 60 | RtlMoveMemory(dest,array,(size_t)size); 61 | } 62 | //+------------------------------------------------------------------+ 63 | //| Read a valid utf-8 string to the MQL environment | 64 | //| With this function, there is no need to copy the string to char | 65 | //| array, and convert with CharArrayToString | 66 | //+------------------------------------------------------------------+ 67 | string StringFromUtf8Pointer(intptr_t psz,int len) 68 | { 69 | if(len < 0) return NULL; 70 | string res; 71 | int required=MultiByteToWideChar(CP_UTF8,0,psz,len,res,0); 72 | StringInit(res,required); 73 | int resLength = MultiByteToWideChar(CP_UTF8,0,psz,len,res,required); 74 | if(resLength != required) 75 | { 76 | return NULL; 77 | } 78 | else 79 | { 80 | return res; 81 | } 82 | } 83 | //+------------------------------------------------------------------+ 84 | //| for null-terminated string | 85 | //+------------------------------------------------------------------+ 86 | string StringFromUtf8Pointer(intptr_t psz) 87 | { 88 | if(psz==0) return NULL; 89 | int len=lstrlen(psz); 90 | if(len==0) return NULL; 91 | return StringFromUtf8Pointer(psz, len); 92 | } 93 | //+------------------------------------------------------------------+ 94 | //| Convert a utf-8 byte array to a string | 95 | //+------------------------------------------------------------------+ 96 | string StringFromUtf8(const uchar &utf8[]) 97 | { 98 | return CharArrayToString(utf8, 0, -1, CP_UTF8); 99 | } 100 | //+------------------------------------------------------------------+ 101 | //| Convert a string to a utf-8 byte array | 102 | //+------------------------------------------------------------------+ 103 | void StringToUtf8(const string str,uchar &utf8[],bool ending=true) 104 | { 105 | if(!ending && str=="") return; 106 | int count=ending ? -1 : StringLen(str); 107 | StringToCharArray(str,utf8,0,count,CP_UTF8); 108 | } 109 | //+------------------------------------------------------------------+ 110 | -------------------------------------------------------------------------------- /Include/SQLite3/Defines.mqh: -------------------------------------------------------------------------------- 1 | //+------------------------------------------------------------------+ 2 | //| Defines.mqh | 3 | //| Copyright 2017, Li Ding | 4 | //| dingmaotu@126.com | 5 | //+------------------------------------------------------------------+ 6 | #property strict 7 | 8 | // The defines come from sqlite3.h 9 | 10 | #define SQLITE_VERSION "3.18.0" 11 | #define SQLITE_VERSION_NUMBER 3018000 12 | #define SQLITE_SOURCE_ID "2017-03-28 18:48:43 424a0d380332858ee55bdebc4af3789f74e70a2b3ba1cf29d84b9b4bcf3e2e37" 13 | 14 | /* 15 | ** CAPI3REF: Fundamental Datatypes 16 | ** KEYWORDS: SQLITE_TEXT 17 | ** 18 | ** (Every value in SQLite has one of five fundamental datatypes: 19 | ** 20 | ** 1. 64-bit signed integer 21 | ** 2. 64-bit IEEE floating point number 22 | ** 3. string 23 | ** 4. BLOB 24 | ** 5. NULL 25 | */ 26 | #define SQLITE_INTEGER 1 27 | #define SQLITE_FLOAT 2 28 | #define SQLITE_BLOB 4 29 | #define SQLITE_NULL 5 30 | #define SQLITE_TEXT 3 31 | #define SQLITE3_TEXT 3 // use only if link with both sqlite2 and sqlite3 32 | 33 | /* 34 | ** CAPI3REF: Text Encodings 35 | ** 36 | ** These constant define integer codes that represent the various 37 | ** text encodings supported by SQLite. 38 | */ 39 | #define SQLITE_UTF8 1 /* IMP: R-37514-35566 */ 40 | #define SQLITE_UTF16LE 2 /* IMP: R-03371-37637 */ 41 | #define SQLITE_UTF16BE 3 /* IMP: R-51971-34154 */ 42 | #define SQLITE_UTF16 4 /* Use native byte order */ 43 | #define SQLITE_ANY 5 /* Deprecated */ 44 | #define SQLITE_UTF16_ALIGNED 8 /* sqlite3_create_collation only */ 45 | 46 | /* 47 | ** CAPI3REF: Result Codes 48 | ** KEYWORDS: {result code definitions} 49 | ** 50 | ** Many SQLite functions return an integer result code from the set shown 51 | ** here in order to indicate success or failure. 52 | ** 53 | ** New error codes may be added in future versions of SQLite. 54 | ** 55 | ** See also: [extended result code definitions] 56 | */ 57 | #define SQLITE_OK 0 /* Successful result */ 58 | /* beginning-of-error-codes */ 59 | #define SQLITE_ERROR 1 /* SQL error or missing database */ 60 | #define SQLITE_INTERNAL 2 /* Internal logic error in SQLite */ 61 | #define SQLITE_PERM 3 /* Access permission denied */ 62 | #define SQLITE_ABORT 4 /* Callback routine requested an abort */ 63 | #define SQLITE_BUSY 5 /* The database file is locked */ 64 | #define SQLITE_LOCKED 6 /* A table in the database is locked */ 65 | #define SQLITE_NOMEM 7 /* A malloc() failed */ 66 | #define SQLITE_READONLY 8 /* Attempt to write a readonly database */ 67 | #define SQLITE_INTERRUPT 9 /* Operation terminated by sqlite3_interrupt()*/ 68 | #define SQLITE_IOERR 10 /* Some kind of disk I/O error occurred */ 69 | #define SQLITE_CORRUPT 11 /* The database disk image is malformed */ 70 | #define SQLITE_NOTFOUND 12 /* Unknown opcode in sqlite3_file_control() */ 71 | #define SQLITE_FULL 13 /* Insertion failed because database is full */ 72 | #define SQLITE_CANTOPEN 14 /* Unable to open the database file */ 73 | #define SQLITE_PROTOCOL 15 /* Database lock protocol error */ 74 | #define SQLITE_EMPTY 16 /* Database is empty */ 75 | #define SQLITE_SCHEMA 17 /* The database schema changed */ 76 | #define SQLITE_TOOBIG 18 /* String or BLOB exceeds size limit */ 77 | #define SQLITE_CONSTRAINT 19 /* Abort due to constraint violation */ 78 | #define SQLITE_MISMATCH 20 /* Data type mismatch */ 79 | #define SQLITE_MISUSE 21 /* Library used incorrectly */ 80 | #define SQLITE_NOLFS 22 /* Uses OS features not supported on host */ 81 | #define SQLITE_AUTH 23 /* Authorization denied */ 82 | #define SQLITE_FORMAT 24 /* Auxiliary database format error */ 83 | #define SQLITE_RANGE 25 /* 2nd parameter to sqlite3_bind out of range */ 84 | #define SQLITE_NOTADB 26 /* File opened that is not a database file */ 85 | #define SQLITE_NOTICE 27 /* Notifications from sqlite3_log() */ 86 | #define SQLITE_WARNING 28 /* Warnings from sqlite3_log() */ 87 | #define SQLITE_ROW 100 /* sqlite3_step() has another row ready */ 88 | #define SQLITE_DONE 101 /* sqlite3_step() has finished executing */ 89 | /* end-of-error-codes */ 90 | 91 | /* 92 | ** CAPI3REF: Extended Result Codes 93 | ** KEYWORDS: {extended result code definitions} 94 | ** 95 | ** In its default configuration, SQLite API routines return one of 30 integer 96 | ** [result codes]. However, experience has shown that many of 97 | ** these result codes are too coarse-grained. They do not provide as 98 | ** much information about problems as programmers might like. In an effort to 99 | ** address this, newer versions of SQLite (version 3.3.8 [dateof:3.3.8] 100 | ** and later) include 101 | ** support for additional result codes that provide more detailed information 102 | ** about errors. These [extended result codes] are enabled or disabled 103 | ** on a per database connection basis using the 104 | ** [sqlite3_extended_result_codes()] API. Or, the extended code for 105 | ** the most recent error can be obtained using 106 | ** [sqlite3_extended_errcode()]. 107 | */ 108 | #define SQLITE_IOERR_READ (SQLITE_IOERR | (1<<8)) 109 | #define SQLITE_IOERR_SHORT_READ (SQLITE_IOERR | (2<<8)) 110 | #define SQLITE_IOERR_WRITE (SQLITE_IOERR | (3<<8)) 111 | #define SQLITE_IOERR_FSYNC (SQLITE_IOERR | (4<<8)) 112 | #define SQLITE_IOERR_DIR_FSYNC (SQLITE_IOERR | (5<<8)) 113 | #define SQLITE_IOERR_TRUNCATE (SQLITE_IOERR | (6<<8)) 114 | #define SQLITE_IOERR_FSTAT (SQLITE_IOERR | (7<<8)) 115 | #define SQLITE_IOERR_UNLOCK (SQLITE_IOERR | (8<<8)) 116 | #define SQLITE_IOERR_RDLOCK (SQLITE_IOERR | (9<<8)) 117 | #define SQLITE_IOERR_DELETE (SQLITE_IOERR | (10<<8)) 118 | #define SQLITE_IOERR_BLOCKED (SQLITE_IOERR | (11<<8)) 119 | #define SQLITE_IOERR_NOMEM (SQLITE_IOERR | (12<<8)) 120 | #define SQLITE_IOERR_ACCESS (SQLITE_IOERR | (13<<8)) 121 | #define SQLITE_IOERR_CHECKRESERVEDLOCK (SQLITE_IOERR | (14<<8)) 122 | #define SQLITE_IOERR_LOCK (SQLITE_IOERR | (15<<8)) 123 | #define SQLITE_IOERR_CLOSE (SQLITE_IOERR | (16<<8)) 124 | #define SQLITE_IOERR_DIR_CLOSE (SQLITE_IOERR | (17<<8)) 125 | #define SQLITE_IOERR_SHMOPEN (SQLITE_IOERR | (18<<8)) 126 | #define SQLITE_IOERR_SHMSIZE (SQLITE_IOERR | (19<<8)) 127 | #define SQLITE_IOERR_SHMLOCK (SQLITE_IOERR | (20<<8)) 128 | #define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21<<8)) 129 | #define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8)) 130 | #define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23<<8)) 131 | #define SQLITE_IOERR_MMAP (SQLITE_IOERR | (24<<8)) 132 | #define SQLITE_IOERR_GETTEMPPATH (SQLITE_IOERR | (25<<8)) 133 | #define SQLITE_IOERR_CONVPATH (SQLITE_IOERR | (26<<8)) 134 | #define SQLITE_IOERR_VNODE (SQLITE_IOERR | (27<<8)) 135 | #define SQLITE_IOERR_AUTH (SQLITE_IOERR | (28<<8)) 136 | #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8)) 137 | #define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8)) 138 | #define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8)) 139 | #define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8)) 140 | #define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8)) 141 | #define SQLITE_CANTOPEN_FULLPATH (SQLITE_CANTOPEN | (3<<8)) 142 | #define SQLITE_CANTOPEN_CONVPATH (SQLITE_CANTOPEN | (4<<8)) 143 | #define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8)) 144 | #define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8)) 145 | #define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2<<8)) 146 | #define SQLITE_READONLY_ROLLBACK (SQLITE_READONLY | (3<<8)) 147 | #define SQLITE_READONLY_DBMOVED (SQLITE_READONLY | (4<<8)) 148 | #define SQLITE_ABORT_ROLLBACK (SQLITE_ABORT | (2<<8)) 149 | #define SQLITE_CONSTRAINT_CHECK (SQLITE_CONSTRAINT | (1<<8)) 150 | #define SQLITE_CONSTRAINT_COMMITHOOK (SQLITE_CONSTRAINT | (2<<8)) 151 | #define SQLITE_CONSTRAINT_FOREIGNKEY (SQLITE_CONSTRAINT | (3<<8)) 152 | #define SQLITE_CONSTRAINT_FUNCTION (SQLITE_CONSTRAINT | (4<<8)) 153 | #define SQLITE_CONSTRAINT_NOTNULL (SQLITE_CONSTRAINT | (5<<8)) 154 | #define SQLITE_CONSTRAINT_PRIMARYKEY (SQLITE_CONSTRAINT | (6<<8)) 155 | #define SQLITE_CONSTRAINT_TRIGGER (SQLITE_CONSTRAINT | (7<<8)) 156 | #define SQLITE_CONSTRAINT_UNIQUE (SQLITE_CONSTRAINT | (8<<8)) 157 | #define SQLITE_CONSTRAINT_VTAB (SQLITE_CONSTRAINT | (9<<8)) 158 | #define SQLITE_CONSTRAINT_ROWID (SQLITE_CONSTRAINT |(10<<8)) 159 | #define SQLITE_NOTICE_RECOVER_WAL (SQLITE_NOTICE | (1<<8)) 160 | #define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8)) 161 | #define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8)) 162 | #define SQLITE_AUTH_USER (SQLITE_AUTH | (1<<8)) 163 | #define SQLITE_OK_LOAD_PERMANENTLY (SQLITE_OK | (1<<8)) 164 | 165 | /* 166 | ** CAPI3REF: Flags For File Open Operations 167 | ** 168 | ** These bit values are intended for use in the 169 | ** 3rd parameter to the [sqlite3_open_v2()] interface and 170 | ** in the 4th parameter to the [sqlite3_vfs.xOpen] method. 171 | */ 172 | #define SQLITE_OPEN_READONLY 0x00000001 /* Ok for sqlite3_open_v2() */ 173 | #define SQLITE_OPEN_READWRITE 0x00000002 /* Ok for sqlite3_open_v2() */ 174 | #define SQLITE_OPEN_CREATE 0x00000004 /* Ok for sqlite3_open_v2() */ 175 | #define SQLITE_OPEN_DELETEONCLOSE 0x00000008 /* VFS only */ 176 | #define SQLITE_OPEN_EXCLUSIVE 0x00000010 /* VFS only */ 177 | #define SQLITE_OPEN_AUTOPROXY 0x00000020 /* VFS only */ 178 | #define SQLITE_OPEN_URI 0x00000040 /* Ok for sqlite3_open_v2() */ 179 | #define SQLITE_OPEN_MEMORY 0x00000080 /* Ok for sqlite3_open_v2() */ 180 | #define SQLITE_OPEN_MAIN_DB 0x00000100 /* VFS only */ 181 | #define SQLITE_OPEN_TEMP_DB 0x00000200 /* VFS only */ 182 | #define SQLITE_OPEN_TRANSIENT_DB 0x00000400 /* VFS only */ 183 | #define SQLITE_OPEN_MAIN_JOURNAL 0x00000800 /* VFS only */ 184 | #define SQLITE_OPEN_TEMP_JOURNAL 0x00001000 /* VFS only */ 185 | #define SQLITE_OPEN_SUBJOURNAL 0x00002000 /* VFS only */ 186 | #define SQLITE_OPEN_MASTER_JOURNAL 0x00004000 /* VFS only */ 187 | #define SQLITE_OPEN_NOMUTEX 0x00008000 /* Ok for sqlite3_open_v2() */ 188 | #define SQLITE_OPEN_FULLMUTEX 0x00010000 /* Ok for sqlite3_open_v2() */ 189 | #define SQLITE_OPEN_SHAREDCACHE 0x00020000 /* Ok for sqlite3_open_v2() */ 190 | #define SQLITE_OPEN_PRIVATECACHE 0x00040000 /* Ok for sqlite3_open_v2() */ 191 | #define SQLITE_OPEN_WAL 0x00080000 /* VFS only */ 192 | 193 | /* Reserved: 0x00F00000 */ 194 | 195 | /* 196 | ** CAPI3REF: Configuration Options 197 | ** KEYWORDS: {configuration option} 198 | ** 199 | ** These constants are the available integer configuration options that 200 | ** can be passed as the first argument to the [sqlite3_config()] interface. 201 | ** 202 | ** New configuration options may be added in future releases of SQLite. 203 | ** Existing configuration options might be discontinued. Applications 204 | ** should check the return code from [sqlite3_config()] to make sure that 205 | ** the call worked. The [sqlite3_config()] interface will return a 206 | ** non-zero [error code] if a discontinued or unsupported configuration option 207 | ** is invoked. 208 | ** 209 | */ 210 | #define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */ 211 | #define SQLITE_CONFIG_MULTITHREAD 2 /* nil */ 212 | #define SQLITE_CONFIG_SERIALIZED 3 /* nil */ 213 | #define SQLITE_CONFIG_MALLOC 4 /* sqlite3_mem_methods* */ 214 | #define SQLITE_CONFIG_GETMALLOC 5 /* sqlite3_mem_methods* */ 215 | #define SQLITE_CONFIG_SCRATCH 6 /* void*, int sz, int N */ 216 | #define SQLITE_CONFIG_PAGECACHE 7 /* void*, int sz, int N */ 217 | #define SQLITE_CONFIG_HEAP 8 /* void*, int nByte, int min */ 218 | #define SQLITE_CONFIG_MEMSTATUS 9 /* boolean */ 219 | #define SQLITE_CONFIG_MUTEX 10 /* sqlite3_mutex_methods* */ 220 | #define SQLITE_CONFIG_GETMUTEX 11 /* sqlite3_mutex_methods* */ 221 | /* previously SQLITE_CONFIG_CHUNKALLOC 12 which is now unused. */ 222 | #define SQLITE_CONFIG_LOOKASIDE 13 /* int int */ 223 | #define SQLITE_CONFIG_PCACHE 14 /* no-op */ 224 | #define SQLITE_CONFIG_GETPCACHE 15 /* no-op */ 225 | #define SQLITE_CONFIG_LOG 16 /* xFunc, void* */ 226 | #define SQLITE_CONFIG_URI 17 /* int */ 227 | #define SQLITE_CONFIG_PCACHE2 18 /* sqlite3_pcache_methods2* */ 228 | #define SQLITE_CONFIG_GETPCACHE2 19 /* sqlite3_pcache_methods2* */ 229 | #define SQLITE_CONFIG_COVERING_INDEX_SCAN 20 /* int */ 230 | #define SQLITE_CONFIG_SQLLOG 21 /* xSqllog, void* */ 231 | #define SQLITE_CONFIG_MMAP_SIZE 22 /* sqlite3_int64, sqlite3_int64 */ 232 | #define SQLITE_CONFIG_WIN32_HEAPSIZE 23 /* int nByte */ 233 | #define SQLITE_CONFIG_PCACHE_HDRSZ 24 /* int *psz */ 234 | #define SQLITE_CONFIG_PMASZ 25 /* unsigned int szPma */ 235 | #define SQLITE_CONFIG_STMTJRNL_SPILL 26 /* int nByte */ 236 | /* 237 | ** CAPI3REF: Database Connection Configuration Options 238 | ** 239 | ** These constants are the available integer configuration options that 240 | ** can be passed as the second argument to the [sqlite3_db_config()] interface. 241 | ** 242 | ** New configuration options may be added in future releases of SQLite. 243 | ** Existing configuration options might be discontinued. Applications 244 | ** should check the return code from [sqlite3_db_config()] to make sure that 245 | ** the call worked. ^The [sqlite3_db_config()] interface will return a 246 | ** non-zero [error code] if a discontinued or unsupported configuration option 247 | ** is invoked. 248 | */ 249 | #define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */ 250 | #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */ 251 | #define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */ 252 | #define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */ 253 | #define SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 1004 /* int int* */ 254 | #define SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION 1005 /* int int* */ 255 | #define SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE 1006 /* int int* */ 256 | 257 | /* 258 | ** CAPI3REF: Run-Time Limit Categories 259 | ** KEYWORDS: {limit category} {*limit categories} 260 | ** 261 | ** These constants define various performance limits 262 | ** that can be lowered at run-time using [sqlite3_limit()]. 263 | ** The synopsis of the meanings of the various limits is shown below. 264 | ** Additional information is available at [limits | Limits in SQLite]. 265 | */ 266 | #define SQLITE_LIMIT_LENGTH 0 267 | #define SQLITE_LIMIT_SQL_LENGTH 1 268 | #define SQLITE_LIMIT_COLUMN 2 269 | #define SQLITE_LIMIT_EXPR_DEPTH 3 270 | #define SQLITE_LIMIT_COMPOUND_SELECT 4 271 | #define SQLITE_LIMIT_VDBE_OP 5 272 | #define SQLITE_LIMIT_FUNCTION_ARG 6 273 | #define SQLITE_LIMIT_ATTACHED 7 274 | #define SQLITE_LIMIT_LIKE_PATTERN_LENGTH 8 275 | #define SQLITE_LIMIT_VARIABLE_NUMBER 9 276 | #define SQLITE_LIMIT_TRIGGER_DEPTH 10 277 | #define SQLITE_LIMIT_WORKER_THREADS 11 278 | 279 | // Constants Defining Special Destructor Behavior 280 | #define SQLITE_STATIC 0 281 | #define SQLITE_TRANSIENT -1 282 | 283 | // Statment status counters 284 | #define SQLITE_STMTSTATUS_FULLSCAN_STEP 1 285 | #define SQLITE_STMTSTATUS_SORT 2 286 | #define SQLITE_STMTSTATUS_AUTOINDEX 3 287 | #define SQLITE_STMTSTATUS_VM_STEP 4 288 | 289 | // Checkpoint mode 290 | #define SQLITE_CHECKPOINT_PASSIVE 0 /* Do as much as possible w/o blocking */ 291 | #define SQLITE_CHECKPOINT_FULL 1 /* Wait for writers, then checkpoint */ 292 | #define SQLITE_CHECKPOINT_RESTART 2 /* Like FULL but wait for for readers */ 293 | #define SQLITE_CHECKPOINT_TRUNCATE 3 /* Like RESTART but also truncate WAL */ 294 | //+------------------------------------------------------------------+ 295 | -------------------------------------------------------------------------------- /Include/SQLite3/Imports.mqh: -------------------------------------------------------------------------------- 1 | //+------------------------------------------------------------------+ 2 | //| Imports.mqh | 3 | //| Copyright 2017, Li Ding | 4 | //| dingmaotu@126.com | 5 | //+------------------------------------------------------------------+ 6 | #property strict 7 | 8 | // always use UTF-8 for all character strings 9 | // always use v2 for advanced features 10 | // only import essential APIs and implement others in MQL 11 | #include "Common.mqh" 12 | #include "Defines.mqh" 13 | 14 | #import "sqlite3.dll" 15 | 16 | intptr_t sqlite3_libversion(void); 17 | intptr_t sqlite3_sourceid(void); 18 | int sqlite3_libversion_number(void); 19 | 20 | int sqlite3_config(int); 21 | int sqlite3_config(int,int); 22 | int sqlite3_config(int,long); 23 | int sqlite3_config(int,int,int); 24 | 25 | int sqlite3_threadsafe(void); 26 | int sqlite3_enable_shared_cache(bool); 27 | 28 | int sqlite3_extended_result_codes(intptr_t,bool onoff); 29 | int sqlite3_enable_load_extension(intptr_t,bool onoff); 30 | int sqlite3_load_extension( 31 | intptr_t,/* Load the extension into this database connection */ 32 | const char &zFile[],/* Name of the shared library containing extension */ 33 | const char &zProc[],/* Entry point. Derived from zFile if 0 */ 34 | intptr_t &pzErrMsg /* Put error message here if not 0 */ 35 | ); 36 | int sqlite3_load_extension( 37 | intptr_t,/* Load the extension into this database connection */ 38 | const char &zFile[],/* Name of the shared library containing extension */ 39 | intptr_t zProc,/* Entry point. Derived from zFile if 0 */ 40 | intptr_t &pzErrMsg /* Put error message here if not 0 */ 41 | ); 42 | 43 | int sqlite3_get_autocommit(intptr_t); 44 | 45 | int sqlite3_initialize(void); 46 | int sqlite3_shutdown(void); 47 | 48 | int sqlite3_release_memory(int); 49 | long sqlite3_soft_heap_limit64(long); 50 | 51 | long sqlite3_memory_used(void); 52 | long sqlite3_memory_highwater(bool resetFlag); 53 | 54 | void sqlite3_free(intptr_t); 55 | 56 | // sqlite3 connection management 57 | int sqlite3_open_v2( 58 | const char &filename[],/* Database filename (UTF-8) */ 59 | intptr_t &pDb,/* OUT: SQLite db handle (sqlite3**) */ 60 | int flags,/* Flags */ 61 | intptr_t zVfs/* Name of VFS module to use */ 62 | ); 63 | int sqlite3_open_v2( 64 | const char &filename[],/* Database filename (UTF-8) */ 65 | intptr_t &pDb,/* OUT: SQLite db handle (sqlite3**) */ 66 | int flags,/* Flags */ 67 | const char &zVfs[]/* Name of VFS module to use */ 68 | ); 69 | int sqlite3_limit(intptr_t,int id,int newVal); 70 | int sqlite3_busy_timeout(intptr_t,int ms); 71 | 72 | intptr_t sqlite3_db_filename(intptr_t,const char &zDbName[]); 73 | int sqlite3_db_readonly(intptr_t,const char &zDbName[]); 74 | int sqlite3_table_column_metadata( 75 | intptr_t,/* Connection handle */ 76 | const char &zDbName[],/* Database name or NULL */ 77 | const char &zTableName[],/* Table name */ 78 | const char &zColumnName[],/* Column name */ 79 | intptr_t &pzDataType,/* OUTPUT: Declared data type */ 80 | intptr_t &pzCollSeq,/* OUTPUT: Collation sequence name */ 81 | bool &isNotNull,/* OUTPUT: True if NOT NULL constraint exists */ 82 | bool &isPrimaryKey,/* OUTPUT: True if column part of PK */ 83 | bool &isAutoinc/* OUTPUT: True if column is auto-increment */ 84 | ); 85 | 86 | int sqlite3_status(int op,int &pCurrent,int &pHighwater,bool reset=false); 87 | int sqlite3_status64(int op,long &pCurrent,long &pHighwater,bool reset=false); 88 | int sqlite3_complete(const char &sql[]); 89 | 90 | void sqlite3_interrupt(intptr_t); 91 | int sqlite3_db_cacheflush(intptr_t); 92 | int sqlite3_db_release_memory(intptr_t); 93 | 94 | int sqlite3_db_status(intptr_t,int op,int &pCurrent,int &pHighwater,bool reset=false); 95 | int sqlite3_db_config(intptr_t,int op,int,intptr_t&); 96 | int sqlite3_db_config(intptr_t,int op,bool,intptr_t); 97 | int sqlite3_db_config(intptr_t,int op,const uchar &dbName[]); 98 | int sqlite3_db_config(intptr_t,int op,intptr_t,int,int); 99 | 100 | long sqlite3_last_insert_rowid(intptr_t); 101 | void sqlite3_set_last_insert_rowid(intptr_t,long); 102 | int sqlite3_changes(intptr_t); 103 | int sqlite3_total_changes(intptr_t); 104 | 105 | int sqlite3_errcode(intptr_t); 106 | int sqlite3_extended_errcode(intptr_t); 107 | intptr_t sqlite3_errmsg(intptr_t); 108 | intptr_t sqlite3_errstr(int); 109 | 110 | int sqlite3_wal_autocheckpoint(intptr_t,int); 111 | int sqlite3_wal_checkpoint_v2( 112 | intptr_t,/* Database handle */ 113 | const char &zDb[],/* Name of attached database (or NULL) */ 114 | int eMode,/* SQLITE_CHECKPOINT_* value */ 115 | int &pnLog,/* OUT: Size of WAL log in frames */ 116 | int &pnCkpt/* OUT: Total number of frames checkpointed */ 117 | ); 118 | int sqlite3_wal_checkpoint_v2( 119 | intptr_t,/* Database handle */ 120 | intptr_t,/* Name of attached database (or NULL) */ 121 | int eMode,/* SQLITE_CHECKPOINT_* value */ 122 | int &pnLog,/* OUT: Size of WAL log in frames */ 123 | int &pnCkpt/* OUT: Total number of frames checkpointed */ 124 | ); 125 | 126 | int sqlite3_close(intptr_t); /* sqlite* */ 127 | 128 | // sqlite3 statement management 129 | int sqlite3_prepare_v2( 130 | intptr_t handle,/* Database handle */ 131 | const char &sql[],/* SQL statement, UTF-8 encoded */ 132 | int bytes,/* Maximum length of sql in bytes. */ 133 | intptr_t &pStmt,/* OUT: Statement handle (sqlite3_stmt **) */ 134 | intptr_t pzTail/* OUT: Pointer to unused portion of zSql (not used and always NULL) */ 135 | ); 136 | int sqlite3_reset(intptr_t pStmt); /* reset a prepared statement */ 137 | int sqlite3_clear_bindings(intptr_t pStmt); /* clear bindings of a prepared statement */ 138 | intptr_t sqlite3_db_handle(intptr_t pStmt); 139 | intptr_t sqlite3_sql(intptr_t pStmt); 140 | intptr_t sqlite3_expanded_sql(intptr_t pStmt); 141 | 142 | int sqlite3_bind_parameter_count(intptr_t pStmt); 143 | intptr_t sqlite3_bind_parameter_name(intptr_t pStmt,int); 144 | int sqlite3_bind_parameter_index(intptr_t pStmt,const char &name[]); 145 | 146 | int sqlite3_bind_blob(intptr_t,int,const uchar &value[],int,intptr_t); 147 | int sqlite3_bind_blob64(intptr_t,int,const uchar &value[],ulong,intptr_t); 148 | int sqlite3_bind_text(intptr_t,int,const char &value[],int,intptr_t); 149 | int sqlite3_bind_text64(intptr_t,int,const char &value[],ulong,intptr_t,uchar encoding); 150 | 151 | int sqlite3_bind_double(intptr_t,int,double); 152 | int sqlite3_bind_int(intptr_t,int,int); 153 | int sqlite3_bind_int64(intptr_t,int,long); 154 | int sqlite3_bind_null(intptr_t,int); 155 | int sqlite3_bind_zeroblob(intptr_t,int,int); 156 | int sqlite3_bind_zeroblob64(intptr_t,int,ulong); 157 | 158 | bool sqlite3_stmt_busy(intptr_t pStmt); 159 | bool sqlite3_stmt_readonly(intptr_t pStmt); 160 | int sqlite3_step(intptr_t pStmt); /* execute a prepared statement */ 161 | int sqlite3_stmt_status(intptr_t,int op,bool resetFlg); 162 | 163 | int sqlite3_data_count(intptr_t pStmt); 164 | int sqlite3_column_count(intptr_t pStmt); 165 | intptr_t sqlite3_column_name(intptr_t pStmt,int); 166 | int sqlite3_column_type(intptr_t pStmt,int i); 167 | int sqlite3_column_bytes(intptr_t pStmt,int i); 168 | 169 | double sqlite3_column_double(intptr_t pStmt,int i); 170 | int sqlite3_column_int(intptr_t pStmt,int i); 171 | long sqlite3_column_int64(intptr_t pStmt,int i); 172 | intptr_t sqlite3_column_text(intptr_t pStmt,int i); 173 | intptr_t sqlite3_column_blob(intptr_t pStmt,int i); 174 | 175 | intptr_t sqlite3_column_decltype(intptr_t pStmt,int); 176 | intptr_t sqlite3_column_database_name(intptr_t,int); 177 | intptr_t sqlite3_column_table_name(intptr_t,int); 178 | intptr_t sqlite3_column_origin_name(intptr_t,int); 179 | 180 | int sqlite3_finalize(intptr_t pStmt); /* destruct sqlite3_stmt */ 181 | 182 | // blob io streaming api 183 | int sqlite3_blob_open( 184 | intptr_t,/* pointer to sqlite3 connection */ 185 | const char &zDb[], 186 | const char &zTable[], 187 | const char &zColumn[], 188 | long row, 189 | int flags, 190 | intptr_t &pBlob 191 | ); 192 | int sqlite3_blob_reopen(intptr_t,long row); 193 | int sqlite3_blob_bytes(intptr_t); 194 | int sqlite3_blob_read(intptr_t,uchar &buf[],int n,int offset); 195 | int sqlite3_blob_write(intptr_t,const uchar &buf[],int n,int offset); 196 | int sqlite3_blob_close(intptr_t); 197 | 198 | // online backup api 199 | intptr_t sqlite3_backup_init( 200 | intptr_t pDest,/* Destination database handle */ 201 | const char &zDestName[],/* Destination database name */ 202 | intptr_t pSource,/* Source database handle */ 203 | const char &zSourceName[]/* Source database name */ 204 | ); 205 | int sqlite3_backup_step(intptr_t,int page); 206 | int sqlite3_backup_finish(intptr_t); 207 | int sqlite3_backup_remaining(intptr_t); 208 | int sqlite3_backup_pagecount(intptr_t); 209 | 210 | intptr_t sqlite3_vfs_find(const char &zVfsName[]); 211 | intptr_t sqlite3_vfs_find(intptr_t); 212 | int sqlite3_vfs_register(intptr_t,bool); 213 | int sqlite3_vfs_unregister(intptr_t); 214 | #import 215 | //+------------------------------------------------------------------+ 216 | //| Basic wrapper for sqlite3_open_v2 | 217 | //+------------------------------------------------------------------+ 218 | int sqlite3_open(const string &filename,intptr_t &handle,int flags,string vfs="") 219 | { 220 | uchar u8filename[]; 221 | StringToUtf8(filename,u8filename); 222 | int res=0; 223 | if(vfs=="") 224 | res=sqlite3_open_v2(u8filename,handle,flags,0); 225 | else 226 | { 227 | uchar u8vfs[]; 228 | StringToUtf8(vfs,u8vfs); 229 | res=sqlite3_open_v2(u8filename,handle,flags,u8vfs); 230 | } 231 | return res; 232 | } 233 | //+------------------------------------------------------------------+ 234 | //| Basic wrapper for sqlite3_prepare_v2 | 235 | //+------------------------------------------------------------------+ 236 | int sqlite3_prepare(const intptr_t handle,const string &sql,intptr_t &stmt) 237 | { 238 | uchar u8sql[]; 239 | StringToUtf8(sql,u8sql); 240 | int res=sqlite3_prepare_v2(handle,u8sql,ArraySize(u8sql),stmt,0); 241 | return res; 242 | } 243 | //+------------------------------------------------------------------+ 244 | -------------------------------------------------------------------------------- /Include/SQLite3/SQLite3.mqh: -------------------------------------------------------------------------------- 1 | //+------------------------------------------------------------------+ 2 | //| SQLite3.mqh | 3 | //| Copyright 2017, Li Ding | 4 | //| dingmaotu@126.com | 5 | //+------------------------------------------------------------------+ 6 | #property strict 7 | 8 | #include "Imports.mqh" 9 | //+------------------------------------------------------------------+ 10 | //| Represents column metadata | 11 | //+------------------------------------------------------------------+ 12 | struct ColumnInfo 13 | { 14 | public: 15 | string DataType; 16 | string CollationSequence; 17 | bool NotNull; 18 | bool PrimaryKey; 19 | bool AutoIncrement; 20 | }; 21 | //+------------------------------------------------------------------+ 22 | //| sqlite3 object representing a connection to a db | 23 | //+------------------------------------------------------------------+ 24 | class SQLite3 25 | { 26 | private: 27 | int m_valid; 28 | intptr_t m_ref; 29 | uchar m_dbName[]; 30 | public: 31 | // version numbers 32 | static int getVersionNumber() {return sqlite3_libversion_number();} 33 | static string getVersion() {return StringFromUtf8Pointer(sqlite3_libversion());} 34 | static string getSourceId() {return StringFromUtf8Pointer(sqlite3_sourceid());} 35 | 36 | // compile time thread safety setting 37 | static bool isThreadSafe() {return sqlite3_threadsafe()!=0;} 38 | 39 | // global configuration before initialize 40 | static int setSingleThreaded() {return sqlite3_config(SQLITE_CONFIG_SINGLETHREAD);} 41 | static int setMultiThreaded() {return sqlite3_config(SQLITE_CONFIG_MULTITHREAD);} 42 | static int setSerialized() {return sqlite3_config(SQLITE_CONFIG_SERIALIZED);} 43 | 44 | static int setMemStatus(bool enabled) {return sqlite3_config(SQLITE_CONFIG_MEMSTATUS,int(enabled));} 45 | static int setUriHandling(bool enabled) {return sqlite3_config(SQLITE_CONFIG_URI,int(enabled));} 46 | static int setLookAside(int before,int after) {return sqlite3_config(SQLITE_CONFIG_LOOKASIDE,before,after);} 47 | 48 | static int setMmapSize(long size) {return sqlite3_config(SQLITE_CONFIG_MMAP_SIZE,size);} 49 | static int setWin32HeapSize(int size) {return sqlite3_config(SQLITE_CONFIG_WIN32_HEAPSIZE,size);} 50 | static int setStatementJournalThreshold(int size) {return sqlite3_config(SQLITE_CONFIG_STMTJRNL_SPILL,size);} 51 | 52 | static int initialize() {return sqlite3_initialize();} 53 | static int shutdown() {return sqlite3_shutdown();} 54 | 55 | static string errorCode2Msg(int code) {return StringFromUtf8Pointer(sqlite3_errstr(code));} 56 | static int status(int op,long ¤t,long &highwater,bool reset=false) {return sqlite3_status64(op,current,highwater,reset);} 57 | 58 | static int releaseMemoryInBytes(int bytes) {return sqlite3_release_memory(bytes);} 59 | static long setSoftHeapLimit(long bytes) {return sqlite3_soft_heap_limit64(bytes);} 60 | 61 | static long getMemoryUsed() {return sqlite3_memory_used(); } 62 | static long getMemoryHighwater() {return sqlite3_memory_highwater(false);} 63 | static long resetMemoryHighwater() {return sqlite3_memory_highwater(true);} 64 | 65 | SQLite3(string filename,int flags,string vfs="") 66 | { 67 | m_valid=sqlite3_open(filename,m_ref,flags,vfs); 68 | if(m_valid!=SQLITE_OK) 69 | { 70 | Print(">>> Error opening database [",filename,"]: ",SQLite3::errorCode2Msg(m_valid)); 71 | } 72 | } 73 | ~SQLite3() 74 | { 75 | if(isValid()) 76 | { 77 | int ret=sqlite3_close(m_ref); 78 | if(ret!=SQLITE_OK) 79 | { 80 | Print(">>> Error close connection: ",getErrorMsg()); 81 | } 82 | } 83 | } 84 | 85 | bool isValid() const {return m_valid==SQLITE_OK;} 86 | 87 | bool isAutoCommit() const { return sqlite3_get_autocommit(m_ref)!=0;} 88 | 89 | bool isReadonly(string db) const 90 | { 91 | char buf[]; 92 | StringToUtf8(db,buf); 93 | return 1==sqlite3_db_readonly(m_ref,buf); 94 | } 95 | bool hasDb(string db) const 96 | { 97 | char buf[]; 98 | StringToUtf8(db,buf); 99 | return -1==sqlite3_db_readonly(m_ref,buf); 100 | } 101 | string getDbFilename(string db) const 102 | { 103 | char buf[]; 104 | StringToUtf8(db,buf); 105 | return StringFromUtf8Pointer(sqlite3_db_filename(m_ref,buf)); 106 | } 107 | int getDbColumnMetadata(string db,string table,string column,ColumnInfo &info) 108 | { 109 | char zDbName[]; 110 | char zTableName[]; 111 | char zColumnName[]; 112 | StringToUtf8(db,zDbName); 113 | StringToUtf8(table,zTableName); 114 | StringToUtf8(column,zColumnName); 115 | intptr_t pDataType; 116 | intptr_t pCollSeq; 117 | int res=sqlite3_table_column_metadata(m_ref,zDbName,zTableName,zColumnName,pDataType,pCollSeq,info.NotNull,info.PrimaryKey,info.AutoIncrement); 118 | if(res==SQLITE_OK) 119 | { 120 | info.DataType=StringFromUtf8Pointer(pDataType); 121 | info.CollationSequence=StringFromUtf8Pointer(pCollSeq); 122 | } 123 | return res; 124 | } 125 | 126 | int setLimit(int id,int value) {return sqlite3_limit(m_ref,id,value);} 127 | int setBusyTimeout(int millis) {return sqlite3_busy_timeout(m_ref, millis);} 128 | 129 | int flush() {return sqlite3_db_cacheflush(m_ref);} 130 | int releaseMemory() {return sqlite3_db_release_memory(m_ref);} 131 | 132 | void interrupt() {sqlite3_interrupt(m_ref);} 133 | 134 | long getLastInsertRowId() {return sqlite3_last_insert_rowid(m_ref);} 135 | void setLastInsertRowId(long id) {sqlite3_set_last_insert_rowid(m_ref,id);} 136 | int getChanges() const {return sqlite3_changes(m_ref);} 137 | int getTotalChanges() const {return sqlite3_total_changes(m_ref);} 138 | 139 | int getErrorCode() const {return sqlite3_errcode(m_ref);} 140 | int getExtendedErrorCode() const {return sqlite3_extended_errcode(m_ref);} 141 | string getErrorMsg() const {return StringFromUtf8Pointer(sqlite3_errmsg(m_ref));} 142 | 143 | int getStatus(int op,int ¤t,int &highwater,bool reset=false) {return sqlite3_db_status(m_ref,op,current,highwater,reset);} 144 | 145 | int setSharedCache(bool value) {return sqlite3_enable_shared_cache(value);} 146 | int setLoadExtension(bool value) {return sqlite3_enable_load_extension(m_ref,value);} 147 | 148 | int setExtendedResultCodes(bool value) {return sqlite3_extended_result_codes(m_ref,value);} 149 | 150 | bool loadExtension(string name,string entry) 151 | { 152 | char u8name[],u8entry[]; 153 | StringToUtf8(name,u8name); 154 | StringToUtf8(name,u8entry); 155 | intptr_t errMsg; 156 | int res= sqlite3_load_extension(m_ref,u8name,u8entry,errMsg); 157 | if(res == SQLITE_OK) return true; 158 | else 159 | { 160 | PrintFormat(">>> Error loading extension module %s: %s",name,StringFromUtf8Pointer(errMsg)); 161 | sqlite3_free(errMsg); 162 | return false; 163 | } 164 | } 165 | 166 | int setAutoCheckpoint(int frameThreshold) {return sqlite3_wal_autocheckpoint(m_ref,frameThreshold);} 167 | int checkpoint(string db,int mode,int &pnLog,int &pnCkpt) 168 | { 169 | if(db==NULL) 170 | return sqlite3_wal_checkpoint_v2(m_ref, 0, mode, pnLog, pnCkpt); 171 | else 172 | { 173 | uchar u8db[]; 174 | StringToUtf8(db,u8db); 175 | return sqlite3_wal_checkpoint_v2(m_ref, u8db, mode, pnLog, pnCkpt); 176 | } 177 | } 178 | 179 | // db config 180 | #define DB_CONFIG(Name,MACRO) \ 181 | bool is##Name##Enabled() const {int res;sqlite3_db_config(m_ref,MACRO,-1,res);return res!=0;}\ 182 | void set##Name##Enabled(bool value) {sqlite3_db_config(m_ref,MACRO,value,0);} 183 | 184 | DB_CONFIG(Trigger,SQLITE_DBCONFIG_ENABLE_TRIGGER) 185 | DB_CONFIG(ForeignKey,SQLITE_DBCONFIG_ENABLE_FKEY) 186 | DB_CONFIG(FTS3Tokenizer,SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER) 187 | DB_CONFIG(LoadExtension,SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION) 188 | DB_CONFIG(CheckpointsOnClose,SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE) 189 | 190 | bool setMainDbName(string name) 191 | { 192 | if(ArraySize(m_dbName) > 0) return false; 193 | StringToUtf8(name,m_dbName); 194 | sqlite3_db_config(m_ref,SQLITE_DBCONFIG_MAINDBNAME,m_dbName); 195 | return true; 196 | } 197 | 198 | int setDbLookAside(int slotSize,int nSlots) {return sqlite3_db_config(m_ref,SQLITE_DBCONFIG_LOOKASIDE,0,slotSize,nSlots);} 199 | // end db config 200 | 201 | //--- intended for internal use 202 | intptr_t ref() const {return m_ref;} 203 | }; 204 | //+------------------------------------------------------------------+ 205 | -------------------------------------------------------------------------------- /Include/SQLite3/Statement.mqh: -------------------------------------------------------------------------------- 1 | //+------------------------------------------------------------------+ 2 | //| Statement.mqh | 3 | //| Copyright 2017, Li Ding | 4 | //| dingmaotu@126.com | 5 | //+------------------------------------------------------------------+ 6 | #property strict 7 | 8 | #include "SQLite3.mqh" 9 | //+------------------------------------------------------------------+ 10 | //| Wraps sqlite3_stmt object | 11 | //+------------------------------------------------------------------+ 12 | class Statement 13 | { 14 | private: 15 | int m_valid; 16 | intptr_t m_ref; 17 | public: 18 | 19 | static bool isComplete(string sql) 20 | { 21 | uchar buf[]; 22 | StringToUtf8(sql,buf); 23 | return 1==sqlite3_complete(buf); 24 | } 25 | 26 | Statement(const SQLite3 &conn,string sql) 27 | { 28 | m_valid=sqlite3_prepare(conn.ref(),sql,m_ref); 29 | } 30 | ~Statement() {if(isValid())sqlite3_finalize(m_ref);} 31 | 32 | bool setSql(string sql) 33 | { 34 | if(isValid()) 35 | { 36 | intptr_t h=getConnectionHandle(); 37 | sqlite3_finalize(m_ref); 38 | m_valid=sqlite3_prepare(h,sql,m_ref); 39 | return m_valid==SQLITE_OK; 40 | } 41 | return false; 42 | } 43 | string getSql() const {return StringFromUtf8Pointer(sqlite3_sql(m_ref));} 44 | string getExpandedSql() const {return StringFromUtf8Pointer(sqlite3_expanded_sql(m_ref));} 45 | intptr_t getConnectionHandle() const {return sqlite3_db_handle(m_ref);} 46 | 47 | bool isValid() const {return m_valid==SQLITE_OK;} 48 | 49 | bool isBusy() const {return sqlite3_stmt_busy(m_ref);} 50 | bool isReadonly() const {return sqlite3_stmt_readonly(m_ref);} 51 | 52 | int getCounter(int op) const {return sqlite3_stmt_status(m_ref,op,false);} 53 | void resetCounter(int op) { sqlite3_stmt_status(m_ref,op,true);} 54 | 55 | int step() { return sqlite3_step(m_ref);} 56 | 57 | int reset() {return sqlite3_reset(m_ref);} 58 | int clearBindings() {return sqlite3_clear_bindings(m_ref);} 59 | 60 | int getParameterCount() const {return sqlite3_bind_parameter_count(m_ref);} 61 | string getParameterName(int i) const {return StringFromUtf8Pointer(sqlite3_bind_parameter_name(m_ref,i));} 62 | int getParameterIndex(string name) const 63 | { 64 | uchar u8name[]; 65 | StringToUtf8(name,u8name); 66 | return sqlite3_bind_parameter_index(m_ref,u8name); 67 | } 68 | 69 | int bind(int i,const uchar &value[],bool copy=true) 70 | { 71 | return sqlite3_bind_blob(m_ref,i,value,ArraySize(value),copy?SQLITE_TRANSIENT:SQLITE_STATIC); 72 | } 73 | int bind(int i,string text) 74 | { 75 | uchar u8text[]; 76 | StringToUtf8(text,u8text); 77 | return sqlite3_bind_text(m_ref,i,u8text,ArraySize(u8text),SQLITE_TRANSIENT); 78 | } 79 | 80 | int bind(int i,double value) {return sqlite3_bind_double(m_ref,i,value);} 81 | int bind(int i,int value) {return sqlite3_bind_int(m_ref,i,value);} 82 | int bind(int i,long value) {return sqlite3_bind_int64(m_ref,i,value);} 83 | int bind(int i) {return sqlite3_bind_null(m_ref,i);} 84 | 85 | int zero(int i,int bytes) {return sqlite3_bind_zeroblob(m_ref,i,bytes);} 86 | int zero(int i,ulong bytes) {return sqlite3_bind_zeroblob64(m_ref,i,bytes);} 87 | 88 | int getDataCount() const {return sqlite3_data_count(m_ref);} 89 | 90 | int getColumnCount() const {return sqlite3_column_count(m_ref);} 91 | string getColumnName(int i) const {return StringFromUtf8Pointer(sqlite3_column_name(m_ref,i));} 92 | int getColumnType(int i) const {return sqlite3_column_type(m_ref,i);} 93 | string getColumnDeclareType(int i) const {return StringFromUtf8Pointer(sqlite3_column_decltype(m_ref,i));} 94 | int getColumnBytes(int i) const {return sqlite3_column_bytes(m_ref,i);} 95 | 96 | string getColumnDatabaseName(int i) const {return StringFromUtf8Pointer(sqlite3_column_database_name(m_ref,i));} 97 | string getColumnTableName(int i) const {return StringFromUtf8Pointer(sqlite3_column_table_name(m_ref,i));} 98 | string getColumnOriginName(int i) const {return StringFromUtf8Pointer(sqlite3_column_origin_name(m_ref,i));} 99 | 100 | void getColumn(int i,double &value) const {value=sqlite3_column_double(m_ref,i);} 101 | void getColumn(int i,int &value) const {value=sqlite3_column_int(m_ref,i);} 102 | void getColumn(int i,long &value) const {value=sqlite3_column_int64(m_ref,i);} 103 | void getColumn(int i,string &value) const 104 | { 105 | intptr_t u8p=0; 106 | u8p=sqlite3_column_text(m_ref,i); 107 | if(u8p>0) value=StringFromUtf8Pointer(u8p); 108 | else value=NULL; 109 | } 110 | void getColumn(int i,uchar &blob[]) const 111 | { 112 | int len=sqlite3_column_bytes(m_ref,i); 113 | if(len==0) 114 | {ArrayFree(blob);return;} 115 | intptr_t blobp=sqlite3_column_blob(m_ref,i); 116 | ArrayResize(blob,len); 117 | ArrayFromPointer(blob,blobp,len); 118 | } 119 | }; 120 | //+------------------------------------------------------------------+ 121 | -------------------------------------------------------------------------------- /Include/SQLite3/Vfs.mqh: -------------------------------------------------------------------------------- 1 | //+------------------------------------------------------------------+ 2 | //| Vfs.mqh | 3 | //| Copyright 2017, Li Ding | 4 | //| dingmaotu@126.com | 5 | //+------------------------------------------------------------------+ 6 | #property strict 7 | 8 | #include "Imports.mqh" 9 | //+------------------------------------------------------------------+ 10 | //| Virtual file system operations | 11 | //+------------------------------------------------------------------+ 12 | struct Vfs 13 | { 14 | public: 15 | intptr_t handle; 16 | 17 | static Vfs getDefault() {Vfs vfs(sqlite3_vfs_find(0)); return vfs;} 18 | static bool find(string name,Vfs &vfs) {char u8[];StringToUtf8(name,u8);vfs.handle=sqlite3_vfs_find(u8);return vfs.handle!=0;} 19 | 20 | Vfs(intptr_t ptr):handle(ptr){} 21 | Vfs(const Vfs&rhs):handle(rhs.handle) {} 22 | void operator=(const Vfs&rhs) {handle=rhs.handle;} 23 | 24 | int register() {return sqlite3_vfs_register(handle,false);} 25 | int registerDefault() {return sqlite3_vfs_register(handle,true);} 26 | int unregister() {return sqlite3_vfs_unregister(handle);} 27 | }; 28 | //+------------------------------------------------------------------+ 29 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Ding Li 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Library/MT4/sqlite3.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dingmaotu/mql-sqlite3/1b5186f7c3c3d4cd27cc648f5273d76eaa8dc593/Library/MT4/sqlite3.dll -------------------------------------------------------------------------------- /Library/MT5/sqlite3.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dingmaotu/mql-sqlite3/1b5186f7c3c3d4cd27cc648f5273d76eaa8dc593/Library/MT5/sqlite3.dll -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # mql-sqlite3 2 | 3 | SQLite3 binding for the MQL language (both 32bit MT4 and 64bit MT5) 4 | 5 | ## Introduction 6 | 7 | This is a complete binding of the [SQLite3](http://sqlite.org/) library (version 8 | 3180000) for the MQL4/5 language used by MetaTrader4/5. 9 | 10 | SQLite is an fast embeded SQL engine written in C 11 | and [widely used](http://sqlite.org/mostdeployed.html) by a lot of projects. We 12 | always have the need to persistent states of Expert Advisors and SQLite seems to 13 | be the best solution. 14 | 15 | This binding tries to remain compatible between MQL4/5. Users of both versions 16 | can use this binding, with a single set of headers. MQL4 and MQL5 are basically 17 | the same in that they are merged in recent versions. The difference is in the 18 | runtime environment (MetaTrader5 is 64bit by default, while MetaTrader4 is 19 | 32bit). The trading system is also different, but it is no concern of this 20 | binding. 21 | 22 | ## Files 23 | 24 | This binding contains three sets of files: 25 | 26 | 1. The binding itself is in the `Include/SQLite3` directory. 27 | 28 | 2. There is a simple testing script called `TestSQLite3.mq4` in `Scripts/Test` 29 | directory. The script files are mq4 by default, but you can change the 30 | extension to mq5 to use them in MetaTrader5. Currently there is only one 31 | script. I am going to add more in the future. 32 | 33 | 3. Precompiled DLLs of both 64bit (`Library/MT5`) and 32bit (`Library/MT4`) are 34 | provided. Copy the corresponding DLLs to the `Library` folder of your 35 | MetaTrader terminal. If you are using MetaTrader5 32bit, use the 32bit 36 | version from `Library/MT4`. The DLLs have no special dependencies and should 37 | work in any Windows version after NT. *Note* that these DLLs are copied from 38 | official binary release, without any modification. You can download/compile 39 | your own if you don't trust these binaries. 40 | 41 | ## API comparison 42 | 43 | Below is a detailed comparison table of MQL and C/C++ APIs. If you are reading 44 | the official documentation, and you want to find the corresponding MQL API for 45 | the C API, use this table. This table also has comments about why a particular 46 | API is not included in this binding. This table might change if new APIs get added. 47 | 48 |
SQLite3 C API | 52 |mql-sqlite3 | 53 |Comment | 54 |
---|---|---|
sqlite3_aggregate_context | 59 |N/A | 60 |for extension | 61 |
sqlite3_aggregate_count | 64 |N/A | 65 |deprecated | 66 |
sqlite3_auto_extension | 69 |N/A | 70 |for extension | 71 |
sqlite3_backup_finish | 74 |Backup::~Backup | 75 |76 | |
sqlite3_backup_init | 79 |Backup::Backup | 80 |81 | |
sqlite3_backup_pagecount | 84 |Backup::getPageCount | 85 |86 | |
sqlite3_backup_remaining | 89 |Backup::getRemaining | 90 |91 | |
sqlite3_backup_step | 94 |Backup::step | 95 |96 | |
sqlite3_bind_blob | 99 |Statement::bind | 100 |101 | |
sqlite3_bind_blob64 | 104 |N/A | 105 |too large for ordinary use | 106 |
sqlite3_bind_double | 109 |Statement::bind | 110 |111 | |
sqlite3_bind_int | 114 |Statement::bind | 115 |116 | |
sqlite3_bind_int64 | 119 |Statement::bind | 120 |121 | |
sqlite3_bind_null | 124 |Statement::bind | 125 |126 | |
sqlite3_bind_parameter_count | 129 |Statement::getParameterCount | 130 |131 | |
sqlite3_bind_parameter_index | 134 |Statement::getParameterIndex | 135 |136 | |
sqlite3_bind_parameter_name | 139 |Statement::getParameterName | 140 |141 | |
sqlite3_bind_text | 144 |Statement::bind | 145 |146 | |
sqlite3_bind_text16 | 149 |N/A | 150 |always UTF-8 | 151 |
sqlite3_bind_text64 | 154 |N/A | 155 |too large for ordinary use | 156 |
sqlite3_bind_value | 159 |N/A | 160 |for extension | 161 |
sqlite3_bind_zeroblob | 164 |Statement::zero | 165 |166 | |
sqlite3_bind_zeroblob64 | 169 |Statement::zero | 170 |171 | |
sqlite3_blob_bytes | 174 |Blob::size | 175 |176 | |
sqlite3_blob_close | 179 |Blob::~Blob | 180 |181 | |
sqlite3_blob_open | 184 |Blob::Blob | 185 |186 | |
sqlite3_blob_read | 189 |Blob::read | 190 |191 | |
sqlite3_blob_reopen | 194 |Blob::moveTo | 195 |196 | |
sqlite3_blob_write | 199 |Blob::write | 200 |201 | |
sqlite3_busy_handler | 204 |N/A | 205 |Need callback | 206 |
sqlite3_busy_timeout | 209 |SQLite3::setBusyTimeout | 210 |211 | |
sqlite3_cancel_auto_extension | 214 |N/A | 215 |for extension | 216 |
sqlite3_changes | 219 |SQLite3::getChanges | 220 |221 | |
sqlite3_clear_bindings | 224 |Statement::clearBindings | 225 |226 | |
sqlite3_close | 229 |N/A | 230 |use v2 | 231 |
sqlite3_close_v2 | 234 |SQLite3::~SQLite3 | 235 |236 | |
sqlite3_collation_needed | 239 |N/A | 240 |for extension | 241 |
sqlite3_collation_needed16 | 244 |N/A | 245 |for extension | 246 |
sqlite3_column_blob | 249 |Statement::getColumn | 250 |251 | |
sqlite3_column_bytes | 254 |Statement::getColumnBytes | 255 |256 | |
sqlite3_column_bytes16 | 259 |N/A | 260 |always UTF-8 | 261 |
sqlite3_column_count | 264 |Statement::getColumnCount | 265 |266 | |
sqlite3_column_database_name | 269 |Statement::getColumnDatabaseName | 270 |271 | |
sqlite3_column_database_name16 | 274 |N/A | 275 |always UTF-8 | 276 |
sqlite3_column_decltype | 279 |Statement::getColumnDeclareType | 280 |281 | |
sqlite3_column_decltype16 | 284 |N/A | 285 |always UTF-8 | 286 |
sqlite3_column_double | 289 |Statement::getColumn | 290 |291 | |
sqlite3_column_int | 294 |Statement::getColumn | 295 |296 | |
sqlite3_column_int64 | 299 |Statement::getColumn | 300 |301 | |
sqlite3_column_name | 304 |Statement::getColumnName | 305 |306 | |
sqlite3_column_name16 | 309 |N/A | 310 |always UTF-8 | 311 |
sqlite3_column_origin_name | 314 |Statement::getColumnOriginName | 315 |316 | |
sqlite3_column_origin_name16 | 319 |N/A | 320 |always UTF-8 | 321 |
sqlite3_column_table_name | 324 |Statement::getColumnTableName | 325 |326 | |
sqlite3_column_table_name16 | 329 |N/A | 330 |always UTF-8 | 331 |
sqlite3_column_text | 334 |Statement::getColumn | 335 |336 | |
sqlite3_column_text16 | 339 |N/A | 340 |always UTF-8 | 341 |
sqlite3_column_type | 344 |Statement::getColumnType | 345 |346 | |
sqlite3_column_value | 349 |N/A | 350 |for extension | 351 |
sqlite3_commit_hook | 354 |N/A | 355 |need callback | 356 |
sqlite3_compileoption_get | 359 |N/A | 360 |diagnostic/optional | 361 |
sqlite3_compileoption_used | 364 |N/A | 365 |diagnostic/optional | 366 |
sqlite3_complete | 369 |Statement::isComplete | 370 |371 | |
sqlite3_complete16 | 374 |N/A | 375 |always UTF-8 | 376 |
sqlite3_config | 379 |SQLite3::set* static methods | 380 |partial | 381 |
sqlite3_context_db_handle | 384 |N/A | 385 |for extension | 386 |
sqlite3_create_collation | 389 |N/A | 390 |for extension | 391 |
sqlite3_create_collation16 | 394 |N/A | 395 |for extension | 396 |
sqlite3_create_collation_v2 | 399 |N/A | 400 |for extension | 401 |
sqlite3_create_function | 404 |N/A | 405 |for extension | 406 |
sqlite3_create_function16 | 409 |N/A | 410 |for extension | 411 |
sqlite3_create_function_v2 | 414 |N/A | 415 |for extension | 416 |
sqlite3_create_module | 419 |N/A | 420 |for extension | 421 |
sqlite3_create_module_v2 | 424 |N/A | 425 |for extension | 426 |
sqlite3_data_count | 429 |Statement::getDataCount | 430 |431 | |
sqlite3_db_cacheflush | 434 |SQLite3::flush | 435 |436 | |
sqlite3_db_config | 439 |SQLite3::setDbLookAside 440 | SQLite3::setMainDbName 441 | SQLite3::isTriggerEnabled 442 | SQLite3::setTriggerEnabled 443 | SQLite3::isForeignKeyEnabled 444 | SQLite3::setForeignKeyEnabled 445 | SQLite3::isFTS3TokenizerEnabled 446 | SQLite3::setFTS3TokenizerEnabled 447 | SQLite3::isLoadExtensionEnabled 448 | SQLite3::setLoadExtensionEnabled 449 | SQLite3::isCheckpointsOnCloseEnabled 450 | SQLite3::setCheckpointsOnCloseEnabled |
451 | 452 | |
sqlite3_db_filename | 455 |SQLite3::getDbFilename | 456 |457 | |
sqlite3_db_handle | 460 |Statement::getConnectionHandle | 461 |462 | |
sqlite3_db_mutex | 465 |N/A | 466 |internal use only | 467 |
sqlite3_db_readonly | 470 |SQLite3::isReadonly | 471 |SQLite3::hasDb check if 472 | contains db | 473 |
sqlite3_db_release_memory | 476 |SQLite3::releaseMemory | 477 |478 | |
sqlite3_db_status | 481 |SQLite3::getStatus | 482 |483 | |
sqlite3_declare_vtab | 486 |N/A | 487 |for extension | 488 |
sqlite3_enable_load_extension | 491 |SQLite3::setLoadExtension | 492 |493 | |
sqlite3_enable_shared_cache | 496 |SQLite3::setSharedCache | 497 |498 | |
sqlite3_errcode | 501 |SQLite3::getErrorCode | 502 |503 | |
sqlite3_errmsg | 506 |SQLite3::getErrorMsg | 507 |508 | |
sqlite3_errmsg16 | 511 |N/A | 512 |always UTF-8 | 513 |
sqlite3_errstr | 516 |SQLite3::errorCode2Msg | 517 |518 | |
sqlite3_exec | 521 |N/A | 522 |convenience wrapper only | 523 |
sqlite3_expanded_sql | 526 |SQLite3::getExpandedSql | 527 |528 | |
sqlite3_expired | 531 |N/A | 532 |deprecated | 533 |
sqlite3_extended_errcode | 536 |SQLite3::getExtendedErrorCode | 537 |538 | |
sqlite3_extended_result_codes | 541 |SQLite3::setResultCodes | 542 |543 | |
sqlite3_file_control | 546 |N/A | 547 |too low level | 548 |
sqlite3_finalize | 551 |SQLite3::~SQLite3 | 552 |553 | |
sqlite3_free | 556 |N/A | 557 |internal use only | 558 |
sqlite3_free_table | 561 |N/A | 562 |convenience wrapper only | 563 |
sqlite3_get_autocommit | 566 |SQLite3::isAutoCommit | 567 |568 | |
sqlite3_get_auxdata | 571 |N/A | 572 |for extension | 573 |
sqlite3_get_table | 576 |N/A | 577 |convenience wrapper only | 578 |
sqlite3_global_recover | 581 |N/A | 582 |deprecated | 583 |
sqlite3_initialize | 586 |SQLite3::initialize | 587 |static | 588 |
sqlite3_interrupt | 591 |SQLite3::interrupt | 592 |593 | |
sqlite3_last_insert_rowid | 596 |SQLite3::getLastInsertRowId | 597 |598 | |
sqlite3_libversion | 601 |SQLite3::getVersion | 602 |static | 603 |
sqlite3_libversion_number | 606 |SQLite3::getVersionNumber | 607 |static | 608 |
sqlite3_limit | 611 |SQLite3::setLimit | 612 |613 | |
sqlite3_load_extension | 616 |SQLite3::loadExtension | 617 |618 | |
sqlite3_log | 621 |N/A | 622 |for extension | 623 |
sqlite3_malloc | 626 |N/A | 627 |internal use only | 628 |
sqlite3_malloc64 | 631 |N/A | 632 |internal use only | 633 |
sqlite3_memory_alarm | 636 |N/A | 637 |deprecated | 638 |
sqlite3_memory_highwater | 641 |SQLite3::getMemoryHighwater, 642 | SQLite3::resetMemoryHighwater | 643 ||
sqlite3_memory_used | 646 |SQLite3::getMemoryUsed | 647 |648 | |
sqlite3_mprintf | 651 |N/A | 652 |internal use only | 653 |
sqlite3_msize | 656 |N/A | 657 |internal use only | 658 |
sqlite3_mutex_alloc | 661 |N/A | 662 |internal use only | 663 |
sqlite3_mutex_enter | 666 |N/A | 667 |internal use only | 668 |
sqlite3_mutex_free | 671 |N/A | 672 |internal use only | 673 |
sqlite3_mutex_held | 676 |N/A | 677 |internal use only | 678 |
sqlite3_mutex_leave | 681 |N/A | 682 |internal use only | 683 |
sqlite3_mutex_notheld | 686 |N/A | 687 |internal use only | 688 |
sqlite3_mutex_try | 691 |N/A | 692 |internal use only | 693 |
sqlite3_next_stmt | 696 |N/A | 697 |no use | 698 |
sqlite3_open | 701 |N/A | 702 |use v2 | 703 |
sqlite3_open16 | 706 |N/A | 707 |always UTF-8 | 708 |
sqlite3_open_v2 | 711 |SQLite3::SQLite3 | 712 |713 | |
sqlite3_os_end | 716 |N/A | 717 |internal use only | 718 |
sqlite3_os_init | 721 |N/A | 722 |internal use only | 723 |
sqlite3_overload_function | 726 |N/A | 727 |for extension | 728 |
sqlite3_prepare | 731 |N/A | 732 |use v2 | 733 |
sqlite3_prepare16 | 736 |N/A | 737 |always UTF-8 | 738 |
sqlite3_prepare16_v2 | 741 |N/A | 742 |always UTF-8 | 743 |
sqlite3_prepare_v2 | 746 |Statement::Statement | 747 |748 | |
sqlite3_preupdate_count | 751 |N/A | 752 |for extension | 753 |
sqlite3_preupdate_depth | 756 |N/A | 757 |for extension | 758 |
sqlite3_preupdate_hook | 761 |N/A | 762 |for extension | 763 |
sqlite3_preupdate_new | 766 |N/A | 767 |for extension | 768 |
sqlite3_preupdate_old | 771 |N/A | 772 |for extension | 773 |
sqlite3_profile | 776 |N/A | 777 |deprecated | 778 |
sqlite3_progress_handler | 781 |N/A | 782 |need callback | 783 |
sqlite3_randomness | 786 |N/A | 787 |use MQL Random | 788 |
sqlite3_realloc | 791 |N/A | 792 |internal use only | 793 |
sqlite3_realloc64 | 796 |N/A | 797 |internal use only | 798 |
sqlite3_release_memory | 801 |SQLite3::releaseMemoryInBytes | 802 |static | 803 |
sqlite3_reset | 806 |Statement::reset | 807 |808 | |
sqlite3_reset_auto_extension | 811 |N/A | 812 |for extension | 813 |
sqlite3_result_blob | 816 |N/A | 817 |for extension | 818 |
sqlite3_result_blob64 | 821 |N/A | 822 |for extension | 823 |
sqlite3_result_double | 826 |N/A | 827 |for extension | 828 |
sqlite3_result_error | 831 |N/A | 832 |for extension | 833 |
sqlite3_result_error16 | 836 |N/A | 837 |for extension | 838 |
sqlite3_result_error_code | 841 |N/A | 842 |for extension | 843 |
sqlite3_result_error_nomem | 846 |N/A | 847 |for extension | 848 |
sqlite3_result_error_toobig | 851 |N/A | 852 |for extension | 853 |
sqlite3_result_int | 856 |N/A | 857 |for extension | 858 |
sqlite3_result_int64 | 861 |N/A | 862 |for extension | 863 |
sqlite3_result_null | 866 |N/A | 867 |for extension | 868 |
sqlite3_result_subtype | 871 |N/A | 872 |for extension | 873 |
sqlite3_result_text | 876 |N/A | 877 |for extension | 878 |
sqlite3_result_text16 | 881 |N/A | 882 |for extension | 883 |
sqlite3_result_text16be | 886 |N/A | 887 |for extension | 888 |
sqlite3_result_text16le | 891 |N/A | 892 |for extension | 893 |
sqlite3_result_text64 | 896 |N/A | 897 |for extension | 898 |
sqlite3_result_value | 901 |N/A | 902 |for extension | 903 |
sqlite3_result_zeroblob | 906 |N/A | 907 |for extension | 908 |
sqlite3_result_zeroblob64 | 911 |N/A | 912 |for extension | 913 |
sqlite3_rollback_hook | 916 |N/A | 917 |need callback | 918 |
sqlite3_set_authorizer | 921 |N/A | 922 |need callback | 923 |
sqlite3_set_auxdata | 926 |N/A | 927 |for extension | 928 |
sqlite3_set_last_insert_rowid | 931 |SQLite3::setLastInsertRowId | 932 |933 | |
sqlite3_shutdown | 936 |SQLite3::shutdown | 937 |938 | |
sqlite3_sleep | 941 |N/A | 942 |use MQL Sleep | 943 |
sqlite3_snapshot_cmp(exp) | 946 |N/A | 947 |experimental | 948 |
sqlite3_snapshot_free(exp) | 951 |N/A | 952 |experimental | 953 |
sqlite3_snapshot_get(exp) | 956 |N/A | 957 |experimental | 958 |
sqlite3_snapshot_open(exp) | 961 |N/A | 962 |experimental | 963 |
sqlite3_snapshot_recover(exp) | 966 |N/A | 967 |experimental | 968 |
sqlite3_snprintf | 971 |N/A | 972 |internal use only | 973 |
sqlite3_soft_heap_limit | 976 |N/A | 977 |deprecated | 978 |
sqlite3_soft_heap_limit64 | 981 |SQLite3::setSoftHeapLimit | 982 |static | 983 |
sqlite3_sourceid | 986 |SQLite3::getSourceId | 987 |static | 988 |
sqlite3_sql | 991 |Statement::getSql | 992 |993 | |
sqlite3_status | 996 |N/A | 997 |use sqlite3_status64 | 998 |
sqlite3_status64 | 1001 |SQLite3::status | 1002 |1003 | |
sqlite3_step | 1006 |Statement::step | 1007 |1008 | |
sqlite3_stmt_busy | 1011 |Statement::isBusy | 1012 |1013 | |
sqlite3_stmt_readonly | 1016 |Statement::isReadonly | 1017 |1018 | |
sqlite3_stmt_scanstatus | 1021 |N/A | 1022 |advanced/optional | 1023 |
sqlite3_stmt_scanstatus_reset | 1026 |N/A | 1027 |advanced/optional | 1028 |
sqlite3_stmt_status | 1031 |Statement::getCounter, 1032 | Statement::resetCounter | 1033 |1034 | |
sqlite3_strglob | 1037 |N/A | 1038 |internal use only | 1039 |
sqlite3_stricmp | 1042 |N/A | 1043 |internal use only | 1044 |
sqlite3_strlike | 1047 |N/A | 1048 |internal use only | 1049 |
sqlite3_strnicmp | 1052 |N/A | 1053 |internal use only | 1054 |
sqlite3_system_errno | 1057 |N/A | 1058 |internal use only | 1059 |
sqlite3_table_column_metadata | 1062 |SQLite3::getDbColumnMetadata | 1063 |1064 | |
sqlite3_test_control | 1067 |N/A | 1068 |internal use only | 1069 |
sqlite3_thread_cleanup | 1072 |N/A | 1073 |deprecated | 1074 |
sqlite3_threadsafe | 1077 |SQLite3::isThreadSafe | 1078 |1079 | |
sqlite3_total_changes | 1082 |SQLite3::getTotalChanges | 1083 |1084 | |
sqlite3_trace | 1087 |N/A | 1088 |deprecated | 1089 |
sqlite3_trace_v2 | 1092 |N/A | 1093 |need callback | 1094 |
sqlite3_transfer_bindings | 1097 |N/A | 1098 |deprecated | 1099 |
sqlite3_unlock_notify | 1102 |N/A | 1103 |need callback | 1104 |
sqlite3_update_hook | 1107 |N/A | 1108 |need callback | 1109 |
sqlite3_uri_boolean | 1112 |N/A | 1113 |for extension | 1114 |
sqlite3_uri_int64 | 1117 |N/A | 1118 |for extension | 1119 |
sqlite3_uri_parameter | 1122 |N/A | 1123 |for extension | 1124 |
sqlite3_user_data | 1127 |N/A | 1128 |for extension | 1129 |
sqlite3_value_blob | 1132 |N/A | 1133 |for extension | 1134 |
sqlite3_value_bytes | 1137 |N/A | 1138 |for extension | 1139 |
sqlite3_value_bytes16 | 1142 |N/A | 1143 |for extension | 1144 |
sqlite3_value_double | 1147 |N/A | 1148 |for extension | 1149 |
sqlite3_value_dup | 1152 |N/A | 1153 |for extension | 1154 |
sqlite3_value_free | 1157 |N/A | 1158 |for extension | 1159 |
sqlite3_value_int | 1162 |N/A | 1163 |for extension | 1164 |
sqlite3_value_int64 | 1167 |N/A | 1168 |for extension | 1169 |
sqlite3_value_numeric_type | 1172 |N/A | 1173 |for extension | 1174 |
sqlite3_value_subtype | 1177 |N/A | 1178 |for extension | 1179 |
sqlite3_value_text | 1182 |N/A | 1183 |for extension | 1184 |
sqlite3_value_text16 | 1187 |N/A | 1188 |for extension | 1189 |
sqlite3_value_text16be | 1192 |N/A | 1193 |for extension | 1194 |
sqlite3_value_text16le | 1197 |N/A | 1198 |for extension | 1199 |
sqlite3_value_type | 1202 |N/A | 1203 |for extension | 1204 |
sqlite3_version | 1207 |N/A | 1208 |not a function | 1209 |
sqlite3_vfs_find | 1212 |Vfs::find, Vfs::getDefault | 1213 |1214 | |
sqlite3_vfs_register | 1217 |Vfs::register, 1218 | Vfs::registerDefault | 1219 |1220 | |
sqlite3_vfs_unregister | 1223 |Vfs::unregister | 1224 |1225 | |
sqlite3_vmprintf | 1228 |N/A | 1229 |internal use only | 1230 |
sqlite3_vsnprintf | 1233 |N/A | 1234 |internal use only | 1235 |
sqlite3_vtab_config | 1238 |N/A | 1239 |for extension | 1240 |
sqlite3_vtab_on_conflict | 1243 |N/A | 1244 |for extension | 1245 |
sqlite3_wal_autocheckpoint | 1248 |SQLite3::setAutoCheckpoint | 1249 |1250 | |
sqlite3_wal_checkpoint | 1253 |N/A | 1254 |use v2 | 1255 |
sqlite3_wal_checkpoint_v2 | 1258 |SQLite3::checkpoint | 1259 |1260 | |
sqlite3_wal_hook | 1263 |N/A | 1264 |need callback | 1265 |