Databases 5 min read

How to Adapt fake2db for GaussDB: A Step-by-Step Guide

This article walks through adapting the open‑source fake2db tool to work with Huawei's GaussDB, covering environment setup, driver installation, code changes, testing, and exposing the generated data via a Django‑based RESTful API.

Huawei Cloud Developer Alliance
Huawei Cloud Developer Alliance
Huawei Cloud Developer Alliance
How to Adapt fake2db for GaussDB: A Step-by-Step Guide

What is fake2db?

fake2db is an open‑source utility that generates test data for development and testing, helping reduce costs, improve data security, and meet compliance requirements for various enterprises and development teams.

Why adapt fake2db to GaussDB?

Since fake2db originally did not support GaussDB, developers need to verify compatibility with GaussDB’s features before using it as the backend database.

How to develop the open‑source project

Start with a thorough requirement analysis, then run the project locally or on Huawei Cloud to ensure the environment is correctly set up before proceeding with development.

Adaptation steps

Fork the fake2db repository to your own account, clone it to your local development environment, and follow the task plan to modify the code for GaussDB support. Install the GaussDB driver package provided by the official site (psycopg2) according to the installation guide.

After installing the driver, purchase GaussDB resources and connect using the following command:

fake2db --db postgresql --rows 5 --host YourIP --port YourPort --username YourUsername --password YourPassword --name YourDBName

This generates test data; you can also apply for vouchers to cover the purchase.

Testing results

Using fake2db with the GaussDB driver successfully creates five tables, each containing five records, which satisfies basic usage scenarios.

Submitting the project

The adapted solution uses Django together with GaussDB (the data generated by fake2db) to expose a RESTful API for data presentation.

Driver considerations

Although the Python package psycopg2 is commonly used, GaussDB is based on PostgreSQL 9 and uses SHA256 for password encryption, whereas the default PostgreSQL driver expects MD5. Using the native PostgreSQL driver requires setting password_encryption_type: 1, which reduces security and is not recommended. Therefore, the GaussDB‑provided driver is the preferred choice.

Community invitation

Developers are encouraged to join the fake2db‑GaussDB adaptation community, ask questions, and share experiences.

databaseDjangoopen-sourceGaussDBfake2db
Huawei Cloud Developer Alliance
Written by

Huawei Cloud Developer Alliance

The Huawei Cloud Developer Alliance creates a tech sharing platform for developers and partners, gathering Huawei Cloud product knowledge, event updates, expert talks, and more. Together we continuously innovate to build the cloud foundation of an intelligent world.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.