Data Source Configuration
Overview
ToChart supports multiple data source types, allowing you to fetch data from different databases and files for chart and dashboard design.
Supported Data Source Types
ToChart currently supports the following data source types:
- MariaDB: MariaDB 5.5+
- MySQL: MySQL 5.7+
- PostgreSQL: PostgreSQL 9.5+
- SQLite: SQLite 3.0+
- Oracle: Oracle 11g+
- SQL Server: SQL Server 2012+
- CSV Files: Single CSV file or batch import by directory
- Excel Files: .xlsx file import
Data Source Management
1. Add a Data Source
- Click the “Data Sources” icon in the left navigation bar
- Click “New Data Source” in the Resource Explorer
- Select the data source type
- Fill in connection details
- Click “Test Connection” to verify
- Click “Save” to save the data source
2. Edit a Data Source
- Select the data source to edit in the Resource Explorer
- Right-click and select “Edit”
- Modify connection details
- Click “Test Connection” to verify changes
- Click “Save” to save changes
3. Delete a Data Source
- Select the data source to delete in the Resource Explorer
- Right-click and select “Delete”
- Click “OK” in the confirmation dialog to delete
4. Copy a Data Source
- Select the data source to copy in the Resource Explorer
- Right-click and select “Copy”
- Modify the new data source name and connection details
- Click “Save” to save the new data source
Data Source Configuration Details
1. MySQL Data Source
Connection Parameters:
- Host/IP: Database server hostname or IP address
- Port: MySQL service port, default 3306
- Database Name: Name of the database to connect to
- Username: Database login username
- Password: Database login password
- Character Set: Database character set, default utf8mb4
- SSL Connection: Whether to use SSL
Advanced Options:
- Connection Timeout: Connection timeout in seconds
- Query Timeout: Query timeout in seconds
- Max Connections: Maximum connection pool size
2. PostgreSQL Data Source
Connection Parameters:
- Host/IP: Database server hostname or IP address
- Port: PostgreSQL service port, default 5432
- Database Name: Name of the database to connect to
- Username: Database login username
- Password: Database login password
- SSL Connection: Whether to use SSL
Advanced Options:
- Connection Timeout: Connection timeout in seconds
- Query Timeout: Query timeout in seconds
- Schema: Database schema, default public
3. SQLite Data Source
Connection Method:
SQLite data sources are located by selecting a database file:
- Database File: SQLite database file path (field:
connection.filename)
SQLite does not require host, port, username, password, or other network connection details.
4. CSV File Data Source
Connection Parameters:
- Management Mode: Single file / Folder
- File Path: CSV file path (single file mode)
- Directory Path: CSV folder path (folder mode)
- File Pattern: Pattern (e.g.,
*.csv) - Recursive Scan: Whether to scan subdirectories
- Generate Summary View: Optionally generate an “all” view that combines matched files via
UNION ALLfor unified queries - Delimiter: Field delimiter, default
, - Include Header: Whether to treat the first row as header
- Encoding: Default
utf-8
CSV/Excel file data sources import files into a local cache database and provide them as tables for the query editor. After file content changes, use “Refresh Connection/Refresh Data Source” on the data source to trigger re-import.
5. Excel File Data Source
Connection Parameters:
- File Path: Excel file path (.xlsx)
- Include Header: Whether to treat the first row as header
- Encoding: Default
utf-8
Data Querying
ToChart supports direct SQL query writing:
- In the chart designer’s “Data” tab, select a data source
- Write SQL queries in the query editor
- Click “Preview Data” to view results
- Adjust queries until satisfactory results are obtained
Data Preview and Testing
1. Data Preview
- On the data source configuration page, click “Test Connection” to verify
- In the query editor, click “Preview Data” to view results
- Data preview shows the first 100 rows for verification
2. Data Testing
- Check data types for correctness
- Verify data integrity
- Evaluate data volume and query performance
Data Source Best Practices
1. Connection Management
- Use connection pooling to improve performance
- Set appropriate connection and query timeouts
- Regularly check data source connection status
2. Query Optimization
- Write efficient SQL queries
- Avoid complex calculations and subqueries
- Use indexes appropriately
- Limit returned data, query only necessary fields
3. Data Security
- Don’t use administrator accounts in data source configuration
- Create dedicated database users with minimum necessary privileges
- Change database passwords regularly
4. Performance Optimization
- Consider data aggregation and pre-computation for large datasets
- Set appropriate data refresh intervals
- Use caching to reduce database queries
FAQ
Connection Failed
- Check if the database server is running
- Verify hostname/IP and port
- Check username and password
- Confirm the database exists
- Check firewall settings to allow database port access
Slow Query Execution
- Optimize SQL queries
- Check database indexes
- Consider increasing database server resources
- Reduce returned data volume
Data Display Issues
- Check data type matching
- Verify data format
- Check data mapping
- Check console logs for detailed error information