DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Fine-Tuning Performance, Resolving Common Issues in FinTech Application With MySQL
  • Optimizing Data Management: Migrating From AWS RDS MySQL to Snowflake
  • Sample Data Generation With Built-In Database Capabilities
  • Java EE 6 Pet Catalog with GlassFish and MySQL

Trending

  • Designing a Java Connector for Software Integrations
  • Breaking Bottlenecks: Applying the Theory of Constraints to Software Development
  • How Trustworthy Is Big Data?
  • How To Develop a Truly Performant Mobile Application in 2025: A Case for Android
  1. DZone
  2. Data Engineering
  3. Databases
  4. Synchronizing Basic Product Data From MySQL With DolphinDB Cached Tables

Synchronizing Basic Product Data From MySQL With DolphinDB Cached Tables

This tutorial describes how to synchronize data using a DolphinDB cached table in an IIoT scenario.

By 
Davis Zhou user avatar
Davis Zhou
·
Dec. 09, 22 · Tutorial
Likes (2)
Comment
Save
Tweet
Share
3.6K Views

Join the DZone community and get the full member experience.

Join For Free

DolphinDB is a high-throughput distributed time-series database, specially designed for big data analysis scenarios in industrial IoT (IIOT) and finance.

Data analysis in DolphinDB is often conducted based on the basic product information (such as the SKU, size, and storage of a device) from an external business platform, which conventionally runs on a relational database. To associate external product information with the time series data in DolphinDB, you can use the cached tables to save the external data fetched through plugins (MySQL, MongoDB, CSV file, etc.) in memory with regular synchronizations.

This tutorial describes how to synchronize data using a DolphinDB cached table in an IIoT scenario.

1. Scenario

In this scenario, a MySQL table must be synchronized every minute with a DolphinDB cached table to update device configuration.

The data to be synchronized is as follows:

2. Solution

Create a cached table in DolphinDB with the following function:

cachedTable(updateFunc, retentionSeconds)

where

  • updateFunc is a function that implements the data synchronization.
  • retentionSeconds is an integer indicating the frequency (in seconds) to update the table in DolphinDB.

2.1 Procedure

  1. Create a table in MySQL (see script).
  2. Install the DolphinDB MySQL plugin.
  3. Synchronize the data from MySQL to DolphinDB (see script below).
Groovy
 login("admin","123456")
//load the MySQL plugin
loadPlugin("yourPluginsPath/mysql/PluginMySQL.txt")
use mysql
//define the function for data synchronization
def syncFunc(){
	//retrieve table data from MySQL
	conn = mysql::connect("127.0.0.1",3306,"root","123456","configDB")
	t = load(conn,"config")
	//return the table
	return t
}

config=cachedTable(syncFunc,60)

select * from config

2.2 Validation

  1. Update the source table by executing the following script in MySQL:
MySQL
update configDB.config set frequency=10,maxvoltage=250,maxec=30;
  1. After the update, print the “config“ tables in MySQL and DolphinDB:

The tables are identical, indicating that changes have been successfully synchronized. 

3. Tips

Data synchronization between databases is a common requirement in Industrial IoT (IIOT) and finance. Its design should not increase inter-system dependency or maintenance cost. The DolphinDB cached tables are a special kind of in-memory table. By synchronizing basic product information to a cached table, you can associate it with the time series data in a distributed database and run business queries smoothly. Note that cached tables are not suitable for real-time data synchronization.

Check out the following tips before deploying your code to production:

  1. Initialize the cached table with non-null values when DolphinDB is started by configuring the startup script startup.dos to improve fault tolerance.
  2. Enable data access through APIs by sharing the cached table across sessions.
  3. Add validation for incoming data.
  4. Add exception handling and logging.
Data synchronization MySQL Relational database IoT

Published at DZone with permission of Davis Chu. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Fine-Tuning Performance, Resolving Common Issues in FinTech Application With MySQL
  • Optimizing Data Management: Migrating From AWS RDS MySQL to Snowflake
  • Sample Data Generation With Built-In Database Capabilities
  • Java EE 6 Pet Catalog with GlassFish and MySQL

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!