-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.js
60 lines (30 loc) · 1.15 KB
/
demo.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
const cannedSql=require('./canned-sql2.js');
demo();
async function demo() {
// Setup your connection config
const config = {
server: 'whatever.database.windows.net',
authentication: {
type: 'default',
options: {
userName: '.........',
password: '*************************'
}
},
options: {
database: 'Demo',
trustServerCertificate: true
}
};
const conn=await cannedSql.connect(config);
const res=await cannedSql.query(conn, "SELECT database_id, [name] FROM sys.databases; SELECT SYSDATETIME() AS dt1;");
console.log(res.results);
const res2=await cannedSql.query(conn, "SELECT @test;", [{ "name": "test", "type": cannedSql.int, "value": 1234}]);
console.log(res2.results);
await cannedSql.begin(conn, cannedSql.SERIALIZABLE);
const res3=await cannedSql.query(conn, "SELECT @@TRANCOUNT AS [@@TRANCOUNT]");
console.log(res3.results);
await cannedSql.rollback(conn);
const res4=await cannedSql.query(conn, "SELECT @@TRANCOUNT AS [@@TRANCOUNT]");
console.log(res4.results);
}