Toggle dark mode

Hi,

📢 Taipy v2.1 is about to be launched! 🚀 ETA:

Day(s)

:

Hour(s)

:

Minute(s)

:

Second(s)

M
December 13, 2022

Taipy 2.0 & MySQL

Welcome to Taipy Forums Taipy Core Taipy 2.0 & MySQL

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #237234
    jmmjmm
    Participant

    Hello all,

    I’m trying to explore some data we have in a MariaDB database, and after I setup 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 :

    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

    — JMM

    #237235
    Florian JactaFlorian Jacta
    Keymaster

    Hi,

    There is an error in the documentation. ‘mysql’ is not supported in this current version but will be in the next big release in January. We are also going to test along the way with MariaDB. The error in the documentation will be fixed soon.

    If you want to make it work now, I would propose you configure your own generic Data Node. By providing a writing and reading function, you can use MariaDB within Taipy. (https://docs.taipy.io/en/latest/manuals/core/config/data-node-config/#generic)

    Best regards,
    Florian

    #237236
    jmmjmm
    Participant

    Hi Florian,

    I’ll try this suggestion and let you know how it went,

    thanks for the help

    — JMM

    #237237
    jmmjmm
    Participant

    Hi Florian,

    I’m a little at a loss here, I read the user manual, and I just don’t get what read_fct and write_fct expect for parameters, and what format they are supposed to return (for write_fct I don’t even know what to return).

    I wrote read_fct to send back a list of tuples I pulled from the DB, the data I want to look at, and with write_fct I don’t know what to do.

    Could you please give a little example to explain how it’s supposed to work ?

    thank you for your help

    regards

    — JMM

    #237238
    Florian JactaFlorian Jacta
    Keymaster

    Hi,

    Here is an example of code you can use to understand how it works:

    _______________
    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’ and the type returned by the function of your task should be in the correct type for ‘write_data’ to work.

    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”)

    If you need more explanation, I can help you or organize a call when you want.

    Best regards,
    Florian
    florian.jacta@taipy.io

    #237385
    jmmjmm
    Participant

    Dear Florian,

    I think I got the knack of it, and wrote an pipeline pulling data from my db and using csv files as buffers.

    As a result, I do not use any SQL related stuff in Taipy.

    My pipeline unfortunately fails with an error :

    pyodbc.Error: (‘01000’, “[01000] [unixODBC][Driver Manager]Can’t open lib ‘ODBC Driver 17 for SQL Server’ : file not found (0) (SQLDriverConnect)”)

    I’m using a Linux PC and no ODBC drivers, thus maybe the ‘ODBC driver missing’ error.

    As I do not use any database from Taipy I shouldn’t have to have such drivers installed IMHO.

    Maybe I’m missing something ?

    best regards

    — JMM

    #237386
    Florian JactaFlorian Jacta
    Keymaster

    Hi,

    So, how do you access your db without doing “SQL-related stuff”? Maybe, try to delete your .data of your project if not already done. If the previous configuration of the CSV data node is still in the .data, it might cause some errors.

    I don’t see why you would get an “ODBC driver missing” error if you don’t use SQL in Taipy.

    If the deletion of your .data doesn’t help, you can maybe contact me by mail to send me a copy of your code reproducing the error or organize a call.

    Best regards,
    Florian

    #237387
    jmmjmm
    Participant

    Hi,

    thank you Florian,

    clearing the .data directory did the trick, the pipeline works now,

    I’m pulling the data from my DB using an orm, and not any of Taipy stuff, as I’m using MariaDB.

    it’s OK now, thanks a lot for your help,

    best regards,

    — JMM

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.