---
lang: en
title: 'API docs: sequelize.sequelizedatasource.execute'
keywords: LoopBack 4.0, LoopBack 4, Node.js, TypeScript, OpenAPI
sidebar: lb4_sidebar
editurl: https://github.com/loopbackio/loopback-next/tree/master/extensions/sequelize
permalink: /doc/en/lb4/apidocs.sequelize.sequelizedatasource.execute.html
---

<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@loopback/sequelize](./sequelize.md) &gt; [SequelizeDataSource](./sequelize.sequelizedatasource.md) &gt; [execute](./sequelize.sequelizedatasource.execute.md)

## SequelizeDataSource.execute() method

Execute a SQL command.

\*\*WARNING:\*\* In general, it is always better to perform database actions through repository methods. Directly executing SQL may lead to unexpected results, corrupted data, security vulnerabilities and other issues.

**Signature:**

```typescript
execute(command: Command, parameters?: NamedParameters | PositionalParameters, options?: Options): Promise<AnyObject>;
```

## Parameters

<table><thead><tr><th>

Parameter


</th><th>

Type


</th><th>

Description


</th></tr></thead>
<tbody><tr><td>

command


</td><td>

Command


</td><td>

A parameterized SQL command or query.


</td></tr>
<tr><td>

parameters


</td><td>

NamedParameters \| PositionalParameters


</td><td>

_(Optional)_ List of parameter values to use.


</td></tr>
<tr><td>

options


</td><td>

Options


</td><td>

_(Optional)_ Additional options, for example `transaction`<!-- -->.


</td></tr>
</tbody></table>
**Returns:**

Promise&lt;AnyObject&gt;

A promise which resolves to the command output. The output type (data structure) is database specific and often depends on the command executed.

## Example


```ts
// MySQL
const result = await db.execute(
  'SELECT * FROM Products WHERE size > ?',
  [42]
);

// PostgreSQL
const result = await db.execute(
  'SELECT * FROM Products WHERE size > $1',
  [42]
);
```


