# Database writer

**URL:** <https://forum.knime.com/t/database-writer/10198>\
**Category:** KNIME Analytics Platform\
**Created:** [May 20, 2014, 5:12pm UTC](https://forum.knime.com/t/database-writer/10198 "2014-05-20T17:12:53Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![SOH979](https://forum-cdn.knime.com/user_avatar/forum.knime.com/soh979/32/2277_2.png) [@SOH979](https://forum.knime.com/u/SOH979)\
**Post date:** [May 20, 2014, 5:12pm UTC](https://forum.knime.com/t/database-writer/10198/1 "2014-05-20T17:12:53Z")

</div>

I'm using a database writer - and it appears to create the tables in mysql and postgresql correctly.  
  
What I'm not clear about is how I might then execute arbitrary SQL statements, e.g. to create indices etc?

Cheers,

Steve.

---

<div class="post-metadata">

**Author:** ![SOH979](https://forum-cdn.knime.com/user_avatar/forum.knime.com/soh979/32/2277_2.png) [@SOH979](https://forum.knime.com/u/SOH979)\
**Post date:** [May 20, 2014, 5:42pm UTC](https://forum.knime.com/t/database-writer/10198/2 "2014-05-20T17:42:26Z")

</div>

Well, Database Writer failed [on second loop through] with error:

'Execute failed: Column "id" of type "StringCell" from input does not match type "VARCHAR" in database at position 16'

In the MySQL DB, field "id" was type "text".

When I changed the column "id" to type "varchar(10)" both in the back-end DB and the node configuration, the node ran fine.

"StringCell" should be compatible with "text" - so is this a bug?

Cheers,

Steve.

&nbsp;

---

<div class="post-metadata">

**Author:** ![James\_Davidson](https://forum-cdn.knime.com/user_avatar/forum.knime.com/james_davidson/32/70_2.png) [@James\_Davidson](https://forum.knime.com/u/James_Davidson)\
**Post date:** [May 21, 2014, 8:27am UTC](https://forum.knime.com/t/database-writer/10198/3 "2014-05-21T08:27:24Z")

</div>

Hi Steve,

You can use the **Database Reader** node to execute SQL other than SELECT statements. &nbsp;However, if you want the node to execute without an error, you must add a 'dummy' SELECT at the end of the SQL to give the node something to return. &nbsp;For example (lifted from a workflow where I do exactly what you are asking for!):

&nbsp;

```
CREATE INDEX fps_maccsfp_idx ON rdk.fps USING gist(maccsfp);

SELECT count(*) FROM rdk.fps
```

&nbsp;

Kind regards

James

---

<div class="post-metadata">

**Author:** ![SOH979](https://forum-cdn.knime.com/user_avatar/forum.knime.com/soh979/32/2277_2.png) [@SOH979](https://forum.knime.com/u/SOH979)\
**Post date:** [May 21, 2014, 1:09pm UTC](https://forum.knime.com/t/database-writer/10198/4 "2014-05-21T13:09:11Z")

</div>

Splendid, I'll try that.

Cheers,

Steve.

---

<div class="post-metadata">

**Author:** ![gabriel](https://forum-cdn.knime.com/user_avatar/forum.knime.com/gabriel/32/61386_2.png) [@gabriel](https://forum.knime.com/u/gabriel)\
**Post date:** [May 21, 2014, 1:19pm UTC](https://forum.knime.com/t/database-writer/10198/5 "2014-05-21T13:19:57Z")

</div>

With KNIME 2.10, we will release a generic SQL Executor nodes, among many other new cool Database Access and Manipulator nodes. Just stay tuned.

---

<div class="post-metadata">

**Author:** ![system](https://forum-cdn.knime.com/uploads/default/original/1X/ab3ccf34482a0329361734a18199390177204f15.png) [@system](https://forum.knime.com/u/system)\
**Post date:** [June 23, 2023, 8:28pm UTC](https://forum.knime.com/t/database-writer/10198/6 "2023-06-23T20:28:33Z")

</div>


