Reputation: 193
I’m trying to explore some data we have in a MariaDB database, and after I set up my environment, I tried to install taipy[mysql] as recommended in the manual.
At this step, I get a warning :
WARNING: taipy 2.0.0 does not provide the extra ‘MySQL’
My pipeline fails with an error : taipy.core.exceptions.exceptions.UnknownDatabaseEngine: Unknown engine: mysql
My Node Config is defined as:
products_cfg = Config.configure_sql_data_node(
id=’products’,
db_username=’xxxxxx’,
db_password=’XxxxxxxxxX’,
db_name=’db’,
db_engine=’mysql’,
db_port=3306,
read_query=get_products_query(),
write_query_builder=write_query_builder,
scope=Scope.GLOBAL
)
Is there a way to use MySQL/MariaDB directly, or do I have to pull data in some intermediate format like CSV or JSON and adapt my pipe?
Thank you for your help,
Best regards
Upvotes: 1
Views: 163
Reputation: 1521
Taipy 2.0 didn't support MySQL. Taipy 2.2 should now support it.
However, you can use the Generic Data Node if you ever need to integrate a specific Data Source like MariaDB or others.
It is a Data Node where a write
and read
function has to be provided. You can then use it in Taipy as a regular Data Node.
In the code below,the Generic Data Node can read and write a CSV. The same can be done for any data sources.
from taipy.core import Config
def read_data(path):
return pd.read_csv(path)
def write_data(data, path):
pd.DataFrame(data).to_csv(path)
generic_data_node_cfg = Config.configure_generic_data_node(id="my_data_node",
read_fct=read_data,
write_fct=write_data,
read_fct_params=("res.csv"),
write_fct_params=("res.csv"))
You also have to be aware of your types. The function of your task will receive the type given by read_data
. The type returned by your task function should be correct for write_data
to work.
In other words, this line of code below should work with "foo" and "bar" optional and function()
, your normal Python function used by your task.
write_data(function(read_data("foo")), "bar")
Upvotes: 1