# Help to use Python do insert variable in SQL code

**URL:** <https://forum.knime.com/t/help-to-use-python-do-insert-variable-in-sql-code/63058>\
**Category:** KNIME Analytics Platform\
**Created:** [March 4, 2023, 2:37pm UTC](https://forum.knime.com/t/help-to-use-python-do-insert-variable-in-sql-code/63058 "2023-03-04T14:37:46Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![mlauber71](https://forum-cdn.knime.com/user_avatar/forum.knime.com/mlauber71/32/73590_2.png) [@mlauber71](https://forum.knime.com/u/mlauber71)\
**Post date:** [March 4, 2023, 4:34pm UTC](https://forum.knime.com/t/help-to-use-python-do-insert-variable-in-sql-code/63058/2 "2023-03-04T16:34:47Z")

</div>

@Aldemir you can export data from within the Python node as Flow Variables or as a dataframe (from a pandas dataframe). The code would look something like this:

```auto
import knime.scripting.io as knio
import numpy as np
import pandas as pd

# bring your string to a Flow Variable
knio.flow_variables['var_txt_cbi'] = txt_cbi

# bring your content to a pandas data frame
output_table = pd.DataFrame({'column_txt_cbi': [txt_cbi]})

# bring the dataframe back to KNIME
knio.output_tables[0] = knio.Table.from_pandas(output_table)

```

Question is would you need Python for what you want to do or are there KNIME nodes that also can do the transformation you want. In any case if you want to use more KNIME and Python it might be good to take a look at the relevant guides. Also I would recommend this sample workflow that presents examples for things you can do with KNIME and Python:

> **[Simple example to make a random forest model with new Python Scrip in KNIME...](https://hub.knime.com/mlauber71/spaces/Public/latest/kn_example_python_iris_2022~HIFbIx26objNVR40)**
>
> Simple example to make a random forest model with new Python Scrip in KNIME 4.6 using the iris dataset. Saving and reusing the model with Pickle Also creating …

Also there is a Space on the KNIME hub with some more examples how to use KNIME and Python:

> **[knime/Python Script Space – 01\_Getting\_Started](https://hub.knime.com/knime/spaces/Python%20Script%20Space/latest/01_Getting_Started~22Yuq_ZDE8fquNgw/)**
>
> contains 5 items

* * *

Data Transfer between KNIME & Python Just Got Faster

> **[Data Transfer between KNIME & Python Just Got Faster | KNIME](https://www.knime.com/blog/python-integration-for-fast-data-transfer)**
>
> The KNIME Python Integration (Labs) boosts performance making Python just as fast in KNIME as it is anywhere else. There is no latency when KNIME transfers tables to Python nodes.

KNIME Python Integration Guide  
[https://docs.knime.com/latest/python\_installation\_guide/#\_introduction](https://docs.knime.com/latest/python_installation_guide/#_introduction)

---

_[View the full topic](https://forum.knime.com/t/help-to-use-python-do-insert-variable-in-sql-code/63058)._
