Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After connecting to the database, converting it to HTML and applying it to the front-end will result in an "get result error" error. We urgently need an answer! #669

Open
soundmemories opened this issue Dec 11, 2024 · 2 comments

Comments

@soundmemories
Copy link

After connecting to the database, converting it to HTML and applying it to the front-end will result in an "get result error" error.
image

backend:

from fastapi.responses import HTMLResponse
import pygwalker as pyg
from pygwalker.data_parsers.database_parser import Connector

@displayController.get("/test", response_class=HTMLResponse)
async def get(request: Request):
    conn = Connector(
        "mysql+pymysql://root:root@192.168.137.36:3306/ruoyi_fastapi",
        "SELECT * FROM sys_menu"
    )
    
    walker = pyg.walk(conn)
    # html_str = pyg.to_html(walker)
    html_str = walker.to_html()
    # df = pd.read_csv(f"vf_admin/upload_path/income.csv", encoding="utf-8")
    # html_str = pyg.to_html(df)
    return html_str

frontend:

<template>
    <div v-html="htmlContent"></div>
</template>

<script setup>
import { ref, onMounted } from 'vue';
import request from '@/utils/request';

const htmlContent = ref('');

const fetchHtmlContent = async () => {
  try {
    
    const html = await request({
      url: "/display/test",
      method: "GET",
    //   headers: {Authorization: "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiMSIsInVzZXJfbmFtZSI6ImFkbWluIiwiZGVwdF9uYW1lIjoiXHU3ODE0XHU1M2QxXHU5MGU4XHU5NWU4Iiwic2Vzc2lvbl9pZCI6ImExYWNhNGIyLWMxNTAtNDhiNS04YjE0LWRmNDFjMWVlZWRkOCIsImxvZ2luX2luZm8iOnsiaXBhZGRyIjpudWxsLCJsb2dpbkxvY2F0aW9uIjoiXHU2NzJhXHU3N2U1IiwiYnJvd3NlciI6IlBvc3RtYW5SdW50aW1lIDcuNDIuMCIsIm9zIjoiT3RoZXIiLCJsb2dpblRpbWUiOiIyMDI0LTEyLTEwIDE1OjMxOjQxIn0sImV4cCI6MTczMzkwMjMwMX0.FcJYLoxbFZostd5kWZjrwMHVdqLX6FnNWyiRVAdX2Xg"
    //   },
    });
    htmlContent.value = html; 
  } catch (error) {
    console.error("error", error);
  }
};

onMounted(fetchHtmlContent);
</script>

<style scoped>

</style>
@ObservedObserver
Copy link
Member

Currently, the to_html API does not support connectors. However, you can use the following alternatives:

  1. Jupyter Notebook: Use pygwalker.walk to work with your data interactively within a Jupyter Notebook.
  2. Web Apps: Use pygwalker with frameworks like Streamlit or Gradio to create web applications.
  3. Direct Customization: For more advanced customization, you can directly use Graphic Walker.

If your dataset is relatively small, another option is to first load your data into a Pandas DataFrame. Once the data is in a DataFrame, you can pass it to pygwalker and use the to_html API as usual.

@soundmemories
Copy link
Author

Currently, the to_html API does not support connectors. However, you can use the following alternatives:

  1. Jupyter Notebook: Use pygwalker.walk to work with your data interactively within a Jupyter Notebook.
  2. Web Apps: Use pygwalker with frameworks like Streamlit or Gradio to create web applications.
  3. Direct Customization: For more advanced customization, you can directly use Graphic Walker.

If your dataset is relatively small, another option is to first load your data into a Pandas DataFrame. Once the data is in a DataFrame, you can pass it to pygwalker and use the to_html API as usual.

Thanks!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants