sqlite3.d.ts 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. // Type definitions for sqlite3
  2. // Project: http://github.com/tryghost/node-sqlite3
  3. /// <reference types="node" />
  4. import events = require("events");
  5. export const OPEN_READONLY: number;
  6. export const OPEN_READWRITE: number;
  7. export const OPEN_CREATE: number;
  8. export const OPEN_FULLMUTEX: number;
  9. export const OPEN_SHAREDCACHE: number;
  10. export const OPEN_PRIVATECACHE: number;
  11. export const OPEN_URI: number;
  12. export const VERSION: string;
  13. export const SOURCE_ID: string;
  14. export const VERSION_NUMBER: number;
  15. export const OK: number;
  16. export const ERROR: number;
  17. export const INTERNAL: number;
  18. export const PERM: number;
  19. export const ABORT: number;
  20. export const BUSY: number;
  21. export const LOCKED: number;
  22. export const NOMEM: number;
  23. export const READONLY: number;
  24. export const INTERRUPT: number
  25. export const IOERR: number;
  26. export const CORRUPT: number
  27. export const NOTFOUND: number;
  28. export const FULL: number;
  29. export const CANTOPEN: number;
  30. export const PROTOCOL: number;
  31. export const EMPTY: number;
  32. export const SCHEMA: number;
  33. export const TOOBIG: number
  34. export const CONSTRAINT: number
  35. export const MISMATCH: number;
  36. export const MISUSE: number;
  37. export const NOLFS: number;
  38. export const AUTH: number
  39. export const FORMAT: number;
  40. export const RANGE: number
  41. export const NOTADB: number;
  42. export const LIMIT_LENGTH: number;
  43. export const LIMIT_SQL_LENGTH: number;
  44. export const LIMIT_COLUMN: number;
  45. export const LIMIT_EXPR_DEPTH: number;
  46. export const LIMIT_COMPOUND_SELECT: number;
  47. export const LIMIT_VDBE_OP: number;
  48. export const LIMIT_FUNCTION_ARG: number;
  49. export const LIMIT_ATTACHED: number;
  50. export const LIMIT_LIKE_PATTERN_LENGTH: number;
  51. export const LIMIT_VARIABLE_NUMBER: number;
  52. export const LIMIT_TRIGGER_DEPTH: number;
  53. export const LIMIT_WORKER_THREADS: number;
  54. export const cached: {
  55. Database(filename: string, callback?: (this: Database, err: Error | null) => void): Database;
  56. Database(filename: string, mode?: number, callback?: (this: Database, err: Error | null) => void): Database;
  57. };
  58. export interface RunResult extends Statement {
  59. lastID: number;
  60. changes: number;
  61. }
  62. export class Statement extends events.EventEmitter {
  63. bind(callback?: (err: Error | null) => void): this;
  64. bind(...params: any[]): this;
  65. reset(callback?: (err: null) => void): this;
  66. finalize(callback?: (err: Error) => void): Database;
  67. run(callback?: (err: Error | null) => void): this;
  68. run(params: any, callback?: (this: RunResult, err: Error | null) => void): this;
  69. run(...params: any[]): this;
  70. get<T>(callback?: (err: Error | null, row?: T) => void): this;
  71. get<T>(params: any, callback?: (this: RunResult, err: Error | null, row?: T) => void): this;
  72. get(...params: any[]): this;
  73. all<T>(callback?: (err: Error | null, rows: T[]) => void): this;
  74. all<T>(params: any, callback?: (this: RunResult, err: Error | null, rows: T[]) => void): this;
  75. all(...params: any[]): this;
  76. each<T>(callback?: (err: Error | null, row: T) => void, complete?: (err: Error | null, count: number) => void): this;
  77. each<T>(params: any, callback?: (this: RunResult, err: Error | null, row: T) => void, complete?: (err: Error | null, count: number) => void): this;
  78. each(...params: any[]): this;
  79. }
  80. export class Database extends events.EventEmitter {
  81. constructor(filename: string, callback?: (err: Error | null) => void);
  82. constructor(filename: string, mode?: number, callback?: (err: Error | null) => void);
  83. close(callback?: (err: Error | null) => void): void;
  84. run(sql: string, callback?: (this: RunResult, err: Error | null) => void): this;
  85. run(sql: string, params: any, callback?: (this: RunResult, err: Error | null) => void): this;
  86. run(sql: string, ...params: any[]): this;
  87. get<T>(sql: string, callback?: (this: Statement, err: Error | null, row: T) => void): this;
  88. get<T>(sql: string, params: any, callback?: (this: Statement, err: Error | null, row: T) => void): this;
  89. get(sql: string, ...params: any[]): this;
  90. all<T>(sql: string, callback?: (this: Statement, err: Error | null, rows: T[]) => void): this;
  91. all<T>(sql: string, params: any, callback?: (this: Statement, err: Error | null, rows: T[]) => void): this;
  92. all(sql: string, ...params: any[]): this;
  93. each<T>(sql: string, callback?: (this: Statement, err: Error | null, row: T) => void, complete?: (err: Error | null, count: number) => void): this;
  94. each<T>(sql: string, params: any, callback?: (this: Statement, err: Error | null, row: T) => void, complete?: (err: Error | null, count: number) => void): this;
  95. each(sql: string, ...params: any[]): this;
  96. exec(sql: string, callback?: (this: Statement, err: Error | null) => void): this;
  97. prepare(sql: string, callback?: (this: Statement, err: Error | null) => void): Statement;
  98. prepare(sql: string, params: any, callback?: (this: Statement, err: Error | null) => void): Statement;
  99. prepare(sql: string, ...params: any[]): Statement;
  100. serialize(callback?: () => void): void;
  101. parallelize(callback?: () => void): void;
  102. on(event: "trace", listener: (sql: string) => void): this;
  103. on(event: "profile", listener: (sql: string, time: number) => void): this;
  104. on(event: "change", listener: (type: string, database: string, table: string, rowid: number) => void): this;
  105. on(event: "error", listener: (err: Error) => void): this;
  106. on(event: "open" | "close", listener: () => void): this;
  107. on(event: string, listener: (...args: any[]) => void): this;
  108. configure(option: "busyTimeout", value: number): void;
  109. configure(option: "limit", id: number, value: number): void;
  110. loadExtension(filename: string, callback?: (err: Error | null) => void): this;
  111. wait(callback?: (param: null) => void): this;
  112. interrupt(): void;
  113. }
  114. export function verbose(): sqlite3;
  115. export interface sqlite3 {
  116. OPEN_READONLY: number;
  117. OPEN_READWRITE: number;
  118. OPEN_CREATE: number;
  119. OPEN_FULLMUTEX: number;
  120. OPEN_SHAREDCACHE: number;
  121. OPEN_PRIVATECACHE: number;
  122. OPEN_URI: number;
  123. VERSION: string;
  124. SOURCE_ID: string;
  125. VERSION_NUMBER: number;
  126. OK: number;
  127. ERROR: number;
  128. INTERNAL: number;
  129. PERM: number;
  130. ABORT: number;
  131. BUSY: number;
  132. LOCKED: number;
  133. NOMEM: number;
  134. READONLY: number;
  135. INTERRUPT: number
  136. IOERR: number;
  137. CORRUPT: number
  138. NOTFOUND: number;
  139. FULL: number;
  140. CANTOPEN: number;
  141. PROTOCOL: number;
  142. EMPTY: number;
  143. SCHEMA: number;
  144. TOOBIG: number
  145. CONSTRAINT: number
  146. MISMATCH: number;
  147. MISUSE: number;
  148. NOLFS: number;
  149. AUTH: number
  150. FORMAT: number;
  151. RANGE: number
  152. NOTADB: number;
  153. LIMIT_LENGTH: number;
  154. LIMIT_SQL_LENGTH: number;
  155. LIMIT_COLUMN: number;
  156. LIMIT_EXPR_DEPTH: number;
  157. LIMIT_COMPOUND_SELECT: number;
  158. LIMIT_VDBE_OP: number;
  159. LIMIT_FUNCTION_ARG: number;
  160. LIMIT_ATTACHED: number;
  161. LIMIT_LIKE_PATTERN_LENGTH: number;
  162. LIMIT_VARIABLE_NUMBER: number;
  163. LIMIT_TRIGGER_DEPTH: number;
  164. LIMIT_WORKER_THREADS: number;
  165. cached: typeof cached;
  166. RunResult: RunResult;
  167. Statement: typeof Statement;
  168. Database: typeof Database;
  169. verbose(): this;
  170. }