1 |
|
2 |
|
3 | import events = require("events");
|
4 |
|
5 | export const OPEN_READONLY: number;
|
6 | export const OPEN_READWRITE: number;
|
7 | export const OPEN_CREATE: number;
|
8 | export const OPEN_SHAREDCACHE: number;
|
9 | export const OPEN_PRIVATECACHE: number;
|
10 | export const OPEN_URI: number;
|
11 |
|
12 | export const cached: {
|
13 | Database(filename: string, callback?: (this: Database, err: Error | null) => void): Database;
|
14 | Database(filename: string, mode?: number, callback?: (this: Database, err: Error | null) => void): Database;
|
15 | };
|
16 |
|
17 | export interface RunResult extends Statement {
|
18 | lastID: number;
|
19 | changes: number;
|
20 | }
|
21 |
|
22 | export class Statement {
|
23 | bind(callback?: (err: Error | null) => void): this;
|
24 | bind(...params: any[]): this;
|
25 |
|
26 | reset(callback?: (err: null) => void): this;
|
27 |
|
28 | finalize(callback?: (err: Error) => void): Database;
|
29 |
|
30 | run(callback?: (err: Error | null) => void): this;
|
31 | run(params: any, callback?: (this: RunResult, err: Error | null) => void): this;
|
32 | run(...params: any[]): this;
|
33 |
|
34 | get(callback?: (err: Error | null, row?: any) => void): this;
|
35 | get(params: any, callback?: (this: RunResult, err: Error | null, row?: any) => void): this;
|
36 | get(...params: any[]): this;
|
37 |
|
38 | all(callback?: (err: Error | null, rows: any[]) => void): this;
|
39 | all(params: any, callback?: (this: RunResult, err: Error | null, rows: any[]) => void): this;
|
40 | all(...params: any[]): this;
|
41 |
|
42 | each(callback?: (err: Error | null, row: any) => void, complete?: (err: Error | null, count: number) => void): this;
|
43 | each(
|
44 | params: any,
|
45 | callback?: (this: RunResult, err: Error | null, row: any) => void,
|
46 | complete?: (err: Error | null, count: number) => void,
|
47 | ): this;
|
48 | each(...params: any[]): this;
|
49 | }
|
50 |
|
51 | export class Database extends events.EventEmitter {
|
52 | constructor(filename: string, callback?: (err: Error | null) => void);
|
53 | constructor(filename: string, mode?: number, callback?: (err: Error | null) => void);
|
54 |
|
55 | close(callback?: (err: Error | null) => void): void;
|
56 |
|
57 | run(sql: string, callback?: (this: RunResult, err: Error | null) => void): this;
|
58 | run(sql: string, params: any, callback?: (this: RunResult, err: Error | null) => void): this;
|
59 | run(sql: string, ...params: any[]): this;
|
60 |
|
61 | get(sql: string, callback?: (this: Statement, err: Error | null, row: any) => void): this;
|
62 | get(sql: string, params: any, callback?: (this: Statement, err: Error | null, row: any) => void): this;
|
63 | get(sql: string, ...params: any[]): this;
|
64 |
|
65 | all(sql: string, callback?: (this: Statement, err: Error | null, rows: any[]) => void): this;
|
66 | all(sql: string, params: any, callback?: (this: Statement, err: Error | null, rows: any[]) => void): this;
|
67 | all(sql: string, ...params: any[]): this;
|
68 |
|
69 | each(
|
70 | sql: string,
|
71 | callback?: (this: Statement, err: Error | null, row: any) => void,
|
72 | complete?: (err: Error | null, count: number) => void,
|
73 | ): this;
|
74 | each(
|
75 | sql: string,
|
76 | params: any,
|
77 | callback?: (this: Statement, err: Error | null, row: any) => void,
|
78 | complete?: (err: Error | null, count: number) => void,
|
79 | ): this;
|
80 | each(sql: string, ...params: any[]): this;
|
81 |
|
82 | exec(sql: string, callback?: (this: Statement, err: Error | null) => void): this;
|
83 |
|
84 | prepare(sql: string, callback?: (this: Statement, err: Error | null) => void): Statement;
|
85 | prepare(sql: string, params: any, callback?: (this: Statement, err: Error | null) => void): Statement;
|
86 | prepare(sql: string, ...params: any[]): Statement;
|
87 |
|
88 | serialize(callback?: () => void): void;
|
89 | parallelize(callback?: () => void): void;
|
90 |
|
91 | on(event: "trace", listener: (sql: string) => void): this;
|
92 | on(event: "profile", listener: (sql: string, time: number) => void): this;
|
93 | on(event: "error", listener: (err: Error) => void): this;
|
94 | on(event: "open" | "close", listener: () => void): this;
|
95 | on(event: string, listener: (...args: any[]) => void): this;
|
96 |
|
97 | configure(option: "busyTimeout", value: number): void;
|
98 | interrupt(): void;
|
99 | }
|
100 |
|
101 | export function verbose(): sqlite3;
|
102 |
|
103 | export interface sqlite3 {
|
104 | OPEN_READONLY: number;
|
105 | OPEN_READWRITE: number;
|
106 | OPEN_CREATE: number;
|
107 | OPEN_SHAREDCACHE: number;
|
108 | OPEN_PRIVATECACHE: number;
|
109 | OPEN_URI: number;
|
110 | cached: typeof cached;
|
111 | RunResult: RunResult;
|
112 | Statement: typeof Statement;
|
113 | Database: typeof Database;
|
114 | verbose(): this;
|
115 | }
|