---
# System prepended metadata

title: Self-practice

---

# Self-practice

---

https://github.com/ccccourse/ws111a/issues


oak
https://deno.land/x/oak@v11.1.0/mod.ts


## Response

An interface to control what response will be sent when the meddleWare finished processing request.

### property

>body 
>the body of the response 

>headers
>header will be return in the response 


## Connect to the Database


### Mysqul

https://deno.land/x/mysql@v2.10.2



Mysql configure

```typescript=
const DBcridential ={
 
    user:"meowhecker",
    db:"nqudb",
    password:"meowhecker",
    localhost:"localhost",
	
}

export{DBcridential}
```


### Execute sql cmd

```
await client.execute(`sqlCommand`);
```



Source code 

Version 1

```typescript
import { Client } from "https://deno.land/x/mysql/mod.ts";
import { DBcridential } from "../DBconfigure.ts";


const client = new Client(DBcridential)

await client.connect();
await client.execute(`USE nqudb`);

const queryTest = async({response},{response:any})=>{
    
    response.body=`ok`
    let result = await client.execute(`SELECT * from test;`)
    console.log(result)
}
export {queryTest}

```
---

Version 2 

```typescript
import { Client } from "https://deno.land/x/mysql/mod.ts";
import { DBcridential } from "../DBconfigure.ts";


const client = new Client(DBcridential)



const queryTest = async({response},{response:any})=>{

    try {
        await client.connect();
        await client.execute(`USE nqudb`);
    
        let result = await client.execute(`SELECT * from test;`)
        console.log(result)
    
        response.status=200
        response.body= result
    } catch (error) {
        response.status=500
        response.body="failed"
    }
}
export {queryTest}

```



---

![](https://i.imgur.com/GnLpfqU.png)



### 
https://deno.land/x/postgres@v0.17.0

It's a lightweight postgreSql driver for Deno

Error(wait to solve)
![](https://i.imgur.com/sWHC9n3.png)


