Skip to content

Commit

Permalink
Merge pull request #701 from Avaiga/fix/core#816-sqldatanote-example-…
Browse files Browse the repository at this point in the history
…not-work

Fix/Core#816 - Update SQLDataNode example to run successfully
  • Loading branch information
trgiangdo authored Nov 3, 2023
2 parents 694dd26 + 59acea5 commit 6279966
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 17 deletions.
5 changes: 2 additions & 3 deletions docs/manuals/core/config/advanced-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,10 @@ the default configuration applies if some values are not provided.
import pandas as pd

def write_orders_plan(data: pd.DataFrame):
insert_data = list(
data[["date", "product_id", "number_of_products"]].itertuples(index=False, name=None))
insert_data = data[["date", "product_id", "number_of_products"]].to_dict("records")
return [
"DELETE FROM orders",
("INSERT INTO orders VALUES (?, ?, ?)", insert_data)
("INSERT INTO orders VALUES (:date, :product_id, :number_of_products)", insert_data)
]

def train(sales_history: pd.DataFrame):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
import pandas as pd

def write_query_builder(data: pd.DataFrame):
insert_data = list(
data[["date", "nb_sales"]].itertuples(index=False, name=None))
insert_data = data[["date", "nb_sales"]].to_dict("records")
return [
"DELETE FROM sales",
("INSERT INTO sales VALUES (?, ?)", insert_data)
("INSERT INTO sales VALUES (:date, :nb_sales)", insert_data)
]

sales_history_cfg = Config.configure_sql_data_node(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
import pandas as pd

def write_query_builder(data: pd.DataFrame):
insert_data = list(
data[["date", "nb_sales"]].itertuples(index=False, name=None))
insert_data = data[["date", "nb_sales"]].to_dict("records")
return [
"DELETE FROM sales",
("INSERT INTO sales VALUES (?, ?)", insert_data)
("INSERT INTO sales VALUES (:date, :nb_sales)", insert_data)
]

sales_history_cfg = Config.configure_sql_table_data_node(
sales_history_cfg = Config.configure_sql_data_node(
id="sales_history",
db_name="taipy",
db_engine="sqlite",
Expand Down
4 changes: 2 additions & 2 deletions docs/manuals/core/entities/code_example/my_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@


def write_orders_plan(data: pd.DataFrame):
insert_data = list(data[["date", "product_id", "number_of_products"]].itertuples(index=False, name=None))
return ["DELETE FROM orders", ("INSERT INTO orders VALUES (?, ?, ?)", insert_data)]
insert_data = data[["date", "product_id", "number_of_products"]].to_dict("records")
return ["DELETE FROM orders", ("INSERT INTO orders VALUES (:date, :product_id, :number_of_products)", insert_data)]


def train(sales_history: pd.DataFrame):
Expand Down
6 changes: 3 additions & 3 deletions docs/manuals/core/entities/data-node-mgt.md
Original file line number Diff line number Diff line change
Expand Up @@ -763,9 +763,9 @@ execute a list of queries returned by the query builder:
```python
data = pandas.DataFrame(
[
{"date": "01/08/2019", "product_id": 1 "number_of_products": 450},
{"date": "01/08/2019", "product_id": 3 "number_of_products": 320},
{"date": "01/08/2019", "product_id": 4 "number_of_products": 350},
{"date": "01/08/2019", "product_id": 1, "number_of_products": 450},
{"date": "01/08/2019", "product_id": 3, "number_of_products": 320},
{"date": "01/08/2019", "product_id": 4, "number_of_products": 350},
]
)
Expand Down
4 changes: 2 additions & 2 deletions docs/manuals/core/scheduling/code_example/my_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@


def write_orders_plan(data: pd.DataFrame):
insert_data = list(data[["date", "product_id", "number_of_products"]].itertuples(index=False, name=None))
return ["DELETE FROM orders", ("INSERT INTO orders VALUES (?, ?, ?)", insert_data)]
insert_data = data[["date", "product_id", "number_of_products"]].to_dict("records")
return ["DELETE FROM orders", ("INSERT INTO orders VALUES (:date, :product_id, :number_of_products)", insert_data)]


def train(sales_history: pd.DataFrame):
Expand Down
6 changes: 6 additions & 0 deletions docs/relnotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ This is the list of changes to Taipy releases as they were published.

## Significant bug fixes

<h4><strong><code>taipy-core</code></strong> 3.1.0 </h4>

- Can not write to a SQLDataNode or a SQLTableDataNode using examples provided by the
documentation.<br/>
See [issue #816](https://github.com/Avaiga/taipy-core/issues/816).


# Community edition: 3.0

Expand Down

0 comments on commit 6279966

Please sign in to comment.