{"id":13147,"date":"2022-04-26T20:13:45","date_gmt":"2022-04-27T03:13:45","guid":{"rendered":"https:\/\/www.couchbase.com\/blog\/?p=13147"},"modified":"2025-06-13T23:04:15","modified_gmt":"2025-06-14T06:04:15","slug":"build-a-python-microservice-with-couchbase-part-3","status":"publish","type":"post","link":"https:\/\/www.couchbase.com\/blog\/build-a-python-microservice-with-couchbase-part-3\/","title":{"rendered":"Build A Python Microservice With Couchbase &#8211; Part 3"},"content":{"rendered":"<h2><span style=\"font-weight: 400;\">Recap<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">In the previous two installments of <a href=\"https:\/\/www.couchbase.com\/blog\/build-a-python-microservice-with-couchbase-part-1\/\" target=\"_blank\" rel=\"noopener\">this series<\/a>, we discussed the drivers behind creating microservices. We also looked at why Couchbase is the perfect datastore to use with such an architecture. We also looked at three variants of a sample user profile microservice. Two were written in Python, and one was written in Node.js for comparison. In this last part of the series, we will discuss one method for generating test data for the microservice schema. <\/span><\/p>\n<h2><span style=\"font-weight: 400;\">Why use test data?<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">Rigorous testing is critical to releasing stable software. Many elements go into a good test strategy. In the past decade, the term \u201cDevOps\u201d is often used to reference both the toolsets used in software development and testing and the culture and processes and procedures that must be in place to achieve rapid, agile development. Regardless of the terminology, there is one common thread \u2013 automation and orchestration. These two things can easily be their own blog series, so we won\u2019t dwell too much on them except to say that test data generation is an essential aspect of DevOps and agile software development and testing.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">I personally have fallen into the trap of not having a good development data set. For expedience, I manually created some data to fit the desired schema so that I could do unit tests on code. But the next day, I realized that the code that worked fine with my small data set didn\u2019t work too well when it was run against a test database with thousands of records and more realistic data.<\/span><\/p>\n<h2><span style=\"font-weight: 400;\">Generating JSON data to test the Python microservice<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">There are many ways to get test data into a test or development database. One method is to copy and sanitize production data if possible. It may not be feasible to have full production copies for multiple development and test environments depending on available resources. Database platforms must be sized appropriately, and care must be taken to remove sensitive data for compliance and security reasons. Complete production copies should be a requirement for regression and pre-prod test environments. Generating synthetic and randomized data with a minimal dataset for unit testing and development is usually suitable.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">With a relational database, it can be challenging to create a database instance with a subset of tables because relational models typically require all the data structures to be present. However, with Couchbase\u2019s JSON document format, it is much easier to do. Looking at the microservice sample, the schema was built around Couchbase\u2019s Scopes and Collections. These could easily be part of a larger schema with more collections and scopes. But all we need are the collections to access keys, user profiles, and the user images, as that is all our service example needs to access to function.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">In the second part of the blog series, we used JMeter to do performance testing. To accomplish performance testing, the database should have at least thousands of records to give JMeter a reasonable dataset for test generation. The microservice simply gets profile elements and returns them via the REST API. The assumption is other application components consume the data and perform business logic using the results.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Revisiting the three profile collections, the following is an example of a document in the <\/span><span style=\"font-weight: 400;\">user_data<\/span><span style=\"font-weight: 400;\"> collection. The service does not enforce whether the picture field has an ID referencing a picture record. The service just returns the profile data or picture data. The assumption is that whatever consumes it upstream will handle that logic.<\/span><\/p>\n<pre class=\"decode-attributes:false lang:js decode:true\">{\r\n\u00a0\u00a0\"record_id\": 1,\r\n\u00a0\u00a0\"name\": \"Michael Jones\",\r\n\u00a0\u00a0\"nickname\": \"mjones\",\r\n\u00a0\u00a0\"picture\": \"\",\r\n\u00a0\u00a0\"user_id\": \"michaeljones2104\",\r\n\u00a0\u00a0\"email\": \"michael.jones@example.com\",\r\n\u00a0\u00a0\"email_verified\": \"True\",\r\n\u00a0\u00a0\"first_name\": \"Michael\",\r\n\u00a0\u00a0\"last_name\": \"Jones\",\r\n\u00a0\u00a0\"address\": \"0208 River Parkway\",\r\n\u00a0\u00a0\"city\": \"Strongdol\",\r\n\u00a0\u00a0\"state\": \"IL\",\r\n\u00a0\u00a0\"zip_code\": \"29954\",\r\n\u00a0\u00a0\"phone\": \"363-555-9036\",\r\n\u00a0\u00a0\"date_of_birth\": \"10\/27\/1958\"\r\n}<\/pre>\n<p>The user_images collection is straightforward with a record ID (that can be referenced by a user profile), an image type field so multiple image codecs can be supported and the Base64 encoded image itself. As noted in the first post in the series, Couchbase supports binary documents, but we used JSON for its portability and extensibility in the sample application. This comes at the expense of some extra network bandwidth to get the data and processor cycles to do the decoding.<\/p>\n<pre class=\"decode-attributes:false lang:js decode:true\">{\r\n\u00a0\u00a0\"record_id\": 1,\r\n\u00a0\u00a0\"type\": \"jpeg\",\r\n\u00a0\u00a0\"image\": \"AAAAD\u2026\"\r\n}<\/pre>\n<p><span style=\"font-weight: 400;\">The basic <\/span><em><span style=\"font-weight: 400;\">service_auth<\/span><\/em><span style=\"font-weight: 400;\"> collection contains the auth token but can be easily extended to include other authentication fields.<\/span><\/p>\n<pre class=\"decode-attributes:false lang:js decode:true\">{\r\n\u00a0\u00a0\"record_id\": 1,\r\n\u00a0\u00a0\"token\": \"6j6nW3KD0ZXodBv1\"\r\n}<\/pre>\n<h3><span style=\"font-weight: 400;\">Generating randomized sample JSON data<\/span><\/h3>\n<p><span style=\"font-weight: 400;\">I wrote a utility called <\/span><span style=\"font-weight: 400;\">cb_perf<\/span><span style=\"font-weight: 400;\"> to generate randomized data and insert it into Couchbase. The utility also does some performance tests to gauge the Python capabilities on a platform. Tools like YCSB use an unrealistic schema as the only goal is to gauge raw performance. I wanted the ability to take arbitrary JSON and insert it with randomized synthetic data.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">To test the sample microservice, I added the schema to <\/span><span style=\"font-weight: 400;\">cb_perf<\/span><span style=\"font-weight: 400;\"> so that I could generate test data sets in any Couchbase cluster. The <\/span><span style=\"font-weight: 400;\">cb_perf<\/span><span style=\"font-weight: 400;\"> utility uses a JSON schema definition file. For each collection, you define the JSON data structure.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">You can specify Jinja2 expressions with variables that map to randomizer data types for each JSON value. That way, each record will be different. You can also define which indexes to create. In this case, we create a primary index and secondary indexes on a few fields.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">It specifies that <\/span><em><span style=\"font-weight: 400;\">record_id<\/span><\/em><span style=\"font-weight: 400;\"> is an ID field and that the overall record count requested should not be overwritten (so we can create as many records as we want).<\/span><\/p>\n<pre class=\"decode-attributes:false lang:js decode:true\">{\r\n\"name\": \"user_data\",\r\n\"schema\": {\r\n\u00a0\u00a0\"record_id\": \"record_id\",\r\n\u00a0\u00a0\"name\": \"{{ rand_first }} {{ rand_last }}\",\r\n\u00a0\u00a0\"nickname\": \"{{ rand_nickname }}\",\r\n\u00a0\u00a0\"picture\": \"\",\r\n\u00a0\u00a0\"user_id\": \"{{ rand_username }}\",\r\n\u00a0\u00a0\"email\": \"{{ rand_email }}\",\r\n\u00a0\u00a0\"email_verified\": \"{{ rand_bool }}\",\r\n\u00a0\u00a0\"first_name\": \"{{ rand_first }}\",\r\n\u00a0\u00a0\"last_name\": \"{{ rand_last }}\",\r\n\u00a0\u00a0\"address\": \"{{ rand_address }}\",\r\n\u00a0\u00a0\"city\": \"{{ rand_city }}\",\r\n\u00a0\u00a0\"state\": \"{{ rand_state }}\",\r\n\u00a0\u00a0\"zip_code\": \"{{ rand_zip_code }}\",\r\n\u00a0\u00a0\"phone\": \"{{ rand_phone }}\",\r\n\u00a0\u00a0\"date_of_birth\": \"{{ rand_dob_1 }}\"\r\n\u00a0\u00a0},\r\n\"idkey\": \"record_id\",\r\n\"primary_index\": true,\r\n\"override_count\": false,\r\n\"indexes\": [\r\n\u00a0\u00a0\"record_id\",\r\n\u00a0\u00a0\"nickname\",\r\n\u00a0\u00a0\"user_id\"\r\n\u00a0\u00a0]\r\n},<\/pre>\n<p>We leverage the <em>cb_perf<\/em> randomizer option for the images collection to create a random JPEG image (it creates a random map of RGB values to make an image of random colors). We define the following:<\/p>\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li><em>Set record_id<\/em> to be the image ID.<\/li>\n<li>Create a primary and secondary index on the ID field.<\/li>\n<li>Use an equal amount of images as the requested record count.<\/li>\n<li>Override the utility\u2019s <i>default batch size <\/i>for asynchronous operations (the default is 100) to set it to 10 as these documents are large (approximately 70KiB per document). We don\u2019t want to create a bottleneck if we load data across a wide area network or the Internet. The default can be used on a private, high-throughput network, such as a cloud VPC or an enterprise data center.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-13149\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2022\/04\/image1-3.png\" alt=\"Sample random image generated by cb_perf\" width=\"214\" height=\"214\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/04\/image1-3.png 128w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/04\/image1-3-65x65.png 65w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/04\/image1-3-50x50.png 50w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/04\/image1-3-20x20.png 20w\" sizes=\"auto, (max-width: 214px) 100vw, 214px\" \/><\/p>\n<pre class=\"decode-attributes:false lang:js decode:true\">{\r\n\"name\": \"user_images\",\r\n\"schema\": {\r\n\u00a0\u00a0\"record_id\": \"record_id\",\r\n\u00a0\u00a0\"type\": \"jpeg\",\r\n\u00a0\u00a0\"image\": \"{{ rand_image }}\"\r\n\u00a0\u00a0},\r\n\"idkey\": \"record_id\",\r\n\"primary_index\": true,\r\n\"override_count\": false,\r\n\"batch_size\": 10,\r\n\"indexes\": [\r\n\u00a0\u00a0\"record_id\"\r\n]\r\n},<\/pre>\n<p><span style=\"font-weight: 400;\">We create only a single auth record in the <\/span><span style=\"font-weight: 400;\">service_auth<\/span><span style=\"font-weight: 400;\"> collection as that is all that is needed.<\/span><\/p>\n<pre class=\"decode-attributes:false lang:js decode:true\">{\r\n\"name\": \"service_auth\",\r\n\"schema\": {\r\n\u00a0\u00a0\"record_id\": \"record_id\",\r\n\u00a0\u00a0\"token\": \"{{ rand_hash }}\"\r\n\u00a0\u00a0},\r\n\"idkey\": \"record_id\",\r\n\"primary_index\": true,\r\n\"override_count\": true,\r\n\"record_count\": 1,\r\n\"indexes\": [\r\n\u00a0\u00a0\"record_id\"\r\n]\r\n}<\/pre>\n<p><span style=\"font-weight: 400;\">The final piece sees us connect image records to profile records. We use the \u201clink\u201d rule as part of the schema definition. The schema rules are run after a data load. We are simply pulling the list of image record keys and updating the picture field in the profile documents to include a reference to the image key.<\/span><\/p>\n<pre class=\"decode-attributes:false lang:js decode:true\">\"rules\": [\r\n{\r\n\u00a0\u00a0\"name\": \"rule0\",\r\n\u00a0\u00a0\"type\": \"link\",\r\n\u00a0\u00a0\"foreign_key\": \"sample_app:profiles:user_data:picture\",\r\n\u00a0\u00a0\"primary_key\": \"sample_app:profiles:user_images:record_id\"\r\n}\r\n]<\/pre>\n<h3><span style=\"font-weight: 400;\">Loading the generated data<\/span><\/h3>\n<p><span style=\"font-weight: 400;\">Cb_perf has a load mode that creates the specified number of records from the requested schema to load the data.<\/span><\/p>\n<pre class=\"decode-attributes:false lang:sh decode:true \">% .\/cb_perf load --host db.example.com --schema profile_demo -u developer -p password --count 1000<\/pre>\n<p><span style=\"font-weight: 400;\">When complete, the data will be loaded and the indexes created. You are ready to run and test the microservices. The utility automatically generates document IDs (the Couchbase document ID in the document metadata, as opposed to the record ID in the document) to be the collection name, plus a colon and the record ID. Here, we can see an example of what was loaded in the Couchbase UI.<\/span><\/p>\n<p><span style=\"font-weight: 400;\"> <img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-13148 size-full\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2022\/04\/image2-3.png\" alt=\"Python series - Viewing randomized JSON data document in Couchbase\" width=\"959\" height=\"588\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/04\/image2-3.png 959w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/04\/image2-3-300x184.png 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/04\/image2-3-768x471.png 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/04\/image2-3-20x12.png 20w\" sizes=\"auto, (max-width: 959px) 100vw, 959px\" \/><\/span><\/p>\n<h3><span style=\"font-weight: 400;\">Up next<\/span><\/h3>\n<p><span style=\"font-weight: 400;\">This completes the Building a Python Microservice with Couchbase series. However, look for future updates on new features being added to <\/span><i><span style=\"font-weight: 400;\">cb_perf <\/span><\/i><span style=\"font-weight: 400;\">and other topics. Thank you for reading this series. I hope you found it informative.<\/span><\/p>\n<h3><span style=\"font-weight: 400;\">Python resources and blog series links<\/span><\/h3>\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><a href=\"https:\/\/github.com\/mminichino\/cbperf\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">Download the cb_perf utility from my GitHub<\/span><\/a><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Read the earlier posts in this series:<\/span>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"2\"><a href=\"https:\/\/www.couchbase.com\/blog\/build-a-python-microservice-with-couchbase-part-1\/\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">Part 1 &#8211; Building a Python Microservice with Couchbase<\/span><\/a><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"2\"><a href=\"https:\/\/www.couchbase.com\/blog\/build-a-python-microservice-with-couchbase-part-2\/\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">Part 2<\/span><\/a> and\u00a0<a href=\"https:\/\/www.couchbase.com\/blog\/build-a-python-microservice-with-couchbase-part-3\/\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">Part 3<\/span><\/a> (final)<\/li>\n<\/ul>\n<\/li>\n<li aria-level=\"2\">Couchbase Python SDK docs &#8211; <a href=\"https:\/\/docs.couchbase.com\/python-sdk\/current\/hello-world\/start-using-sdk.html\" target=\"_blank\" rel=\"noopener\">Getting Started with the Python SDK<\/a><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3><span style=\"font-weight: 400;\">Random fun fact<\/span><\/h3>\n<p><span style=\"font-weight: 400;\">In a universe far, far away in a different technological time, Perl was the popular interpreted language. It grew from a text-processing language (like the classic UNIX AWK) to a ubiquitous general-purpose language. Between 1996 and 2000, the Perl community decided to borrow from the long-standing Obfuscated C competition and held Obfuscated Perl competitions. Perl\u2019s loose, free-form syntax can certainly lead to difficult-to-decipher programs, so it is only natural to have had such a competition. Every programmer at some point looks at something they wrote, perhaps fueled by caffeine and sleep deprivation, and wonders what it does.\u00a0<\/span><\/p>\n<pre class=\"decode-attributes:false lang:default decode:true \">python3 -c \"print(bytearray([ord(b'a')+b%26 for b in [19,7,0,13,10,18]]).decode('utf-8'))\"<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Recap In the previous two installments of this series, we discussed the drivers behind creating microservices. We also looked at why Couchbase is the perfect datastore to use with such an architecture. We also looked at three variants of a [&hellip;]<\/p>\n","protected":false},"author":81015,"featured_media":13151,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[1814,1816,1819,9139,2201],"tags":[1261,2103,1877],"ppma_author":[9550],"class_list":["post-13147","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-application-design","category-couchbase-server","category-data-modeling","category-python","category-tools-sdks","tag-json","tag-microservices","tag-testing"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.7.1 (Yoast SEO v25.7) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Build A Python Microservice With Couchbase - Part 3<\/title>\n<meta name=\"description\" content=\"Python series - part 3 of building a microservice, in this post we create randomized JSON sample data for testing microservices in Couchbase.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.couchbase.com\/blog\/build-a-python-microservice-with-couchbase-part-3\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Build A Python Microservice With Couchbase - Part 3\" \/>\n<meta property=\"og:description\" content=\"Python series - part 3 of building a microservice, in this post we create randomized JSON sample data for testing microservices in Couchbase.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.couchbase.com\/blog\/build-a-python-microservice-with-couchbase-part-3\/\" \/>\n<meta property=\"og:site_name\" content=\"The Couchbase Blog\" \/>\n<meta property=\"article:published_time\" content=\"2022-04-27T03:13:45+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-06-14T06:04:15+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/04\/build-microservice-python-couchbase-scaled.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"2560\" \/>\n\t<meta property=\"og:image:height\" content=\"1341\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Michael Minichino\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Michael Minichino\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/build-a-python-microservice-with-couchbase-part-3\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/build-a-python-microservice-with-couchbase-part-3\/\"},\"author\":{\"name\":\"Michael Minichino\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/15ea6a51d53d4739913c98d25a8d7e77\"},\"headline\":\"Build A Python Microservice With Couchbase &#8211; Part 3\",\"datePublished\":\"2022-04-27T03:13:45+00:00\",\"dateModified\":\"2025-06-14T06:04:15+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/build-a-python-microservice-with-couchbase-part-3\/\"},\"wordCount\":1367,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/build-a-python-microservice-with-couchbase-part-3\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/04\/build-microservice-python-couchbase-scaled.jpg\",\"keywords\":[\"JSON\",\"microservices\",\"testing\"],\"articleSection\":[\"Application Design\",\"Couchbase Server\",\"Data Modeling\",\"Python\",\"Tools &amp; SDKs\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/build-a-python-microservice-with-couchbase-part-3\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/build-a-python-microservice-with-couchbase-part-3\/\",\"url\":\"https:\/\/www.couchbase.com\/blog\/build-a-python-microservice-with-couchbase-part-3\/\",\"name\":\"Build A Python Microservice With Couchbase - Part 3\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/build-a-python-microservice-with-couchbase-part-3\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/build-a-python-microservice-with-couchbase-part-3\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/04\/build-microservice-python-couchbase-scaled.jpg\",\"datePublished\":\"2022-04-27T03:13:45+00:00\",\"dateModified\":\"2025-06-14T06:04:15+00:00\",\"description\":\"Python series - part 3 of building a microservice, in this post we create randomized JSON sample data for testing microservices in Couchbase.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/build-a-python-microservice-with-couchbase-part-3\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/build-a-python-microservice-with-couchbase-part-3\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/build-a-python-microservice-with-couchbase-part-3\/#primaryimage\",\"url\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/04\/build-microservice-python-couchbase-scaled.jpg\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/04\/build-microservice-python-couchbase-scaled.jpg\",\"width\":2560,\"height\":1341,\"caption\":\"Creating test data for Python microservices in Couchbase\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/build-a-python-microservice-with-couchbase-part-3\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.couchbase.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Build A Python Microservice With Couchbase &#8211; Part 3\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#website\",\"url\":\"https:\/\/www.couchbase.com\/blog\/\",\"name\":\"The Couchbase Blog\",\"description\":\"Couchbase, the NoSQL Database\",\"publisher\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.couchbase.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\",\"name\":\"The Couchbase Blog\",\"url\":\"https:\/\/www.couchbase.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png\",\"width\":218,\"height\":34,\"caption\":\"The Couchbase Blog\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/15ea6a51d53d4739913c98d25a8d7e77\",\"name\":\"Michael Minichino\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/ed87fc8ff8aedc56f9872fbd77382f29\",\"url\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/03\/Screen-Shot-2022-03-28-at-12.40.06-PM.png\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/03\/Screen-Shot-2022-03-28-at-12.40.06-PM.png\",\"caption\":\"Michael Minichino\"},\"url\":\"https:\/\/www.couchbase.com\/blog\/author\/michael-minichino\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Build A Python Microservice With Couchbase - Part 3","description":"Python series - part 3 of building a microservice, in this post we create randomized JSON sample data for testing microservices in Couchbase.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.couchbase.com\/blog\/build-a-python-microservice-with-couchbase-part-3\/","og_locale":"en_US","og_type":"article","og_title":"Build A Python Microservice With Couchbase - Part 3","og_description":"Python series - part 3 of building a microservice, in this post we create randomized JSON sample data for testing microservices in Couchbase.","og_url":"https:\/\/www.couchbase.com\/blog\/build-a-python-microservice-with-couchbase-part-3\/","og_site_name":"The Couchbase Blog","article_published_time":"2022-04-27T03:13:45+00:00","article_modified_time":"2025-06-14T06:04:15+00:00","og_image":[{"width":2560,"height":1341,"url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/04\/build-microservice-python-couchbase-scaled.jpg","type":"image\/jpeg"}],"author":"Michael Minichino","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Michael Minichino","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.couchbase.com\/blog\/build-a-python-microservice-with-couchbase-part-3\/#article","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/build-a-python-microservice-with-couchbase-part-3\/"},"author":{"name":"Michael Minichino","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/15ea6a51d53d4739913c98d25a8d7e77"},"headline":"Build A Python Microservice With Couchbase &#8211; Part 3","datePublished":"2022-04-27T03:13:45+00:00","dateModified":"2025-06-14T06:04:15+00:00","mainEntityOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/build-a-python-microservice-with-couchbase-part-3\/"},"wordCount":1367,"commentCount":0,"publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/build-a-python-microservice-with-couchbase-part-3\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/04\/build-microservice-python-couchbase-scaled.jpg","keywords":["JSON","microservices","testing"],"articleSection":["Application Design","Couchbase Server","Data Modeling","Python","Tools &amp; SDKs"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.couchbase.com\/blog\/build-a-python-microservice-with-couchbase-part-3\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.couchbase.com\/blog\/build-a-python-microservice-with-couchbase-part-3\/","url":"https:\/\/www.couchbase.com\/blog\/build-a-python-microservice-with-couchbase-part-3\/","name":"Build A Python Microservice With Couchbase - Part 3","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/build-a-python-microservice-with-couchbase-part-3\/#primaryimage"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/build-a-python-microservice-with-couchbase-part-3\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/04\/build-microservice-python-couchbase-scaled.jpg","datePublished":"2022-04-27T03:13:45+00:00","dateModified":"2025-06-14T06:04:15+00:00","description":"Python series - part 3 of building a microservice, in this post we create randomized JSON sample data for testing microservices in Couchbase.","breadcrumb":{"@id":"https:\/\/www.couchbase.com\/blog\/build-a-python-microservice-with-couchbase-part-3\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.couchbase.com\/blog\/build-a-python-microservice-with-couchbase-part-3\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/build-a-python-microservice-with-couchbase-part-3\/#primaryimage","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/04\/build-microservice-python-couchbase-scaled.jpg","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/04\/build-microservice-python-couchbase-scaled.jpg","width":2560,"height":1341,"caption":"Creating test data for Python microservices in Couchbase"},{"@type":"BreadcrumbList","@id":"https:\/\/www.couchbase.com\/blog\/build-a-python-microservice-with-couchbase-part-3\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.couchbase.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Build A Python Microservice With Couchbase &#8211; Part 3"}]},{"@type":"WebSite","@id":"https:\/\/www.couchbase.com\/blog\/#website","url":"https:\/\/www.couchbase.com\/blog\/","name":"The Couchbase Blog","description":"Couchbase, the NoSQL Database","publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.couchbase.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.couchbase.com\/blog\/#organization","name":"The Couchbase Blog","url":"https:\/\/www.couchbase.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","width":218,"height":34,"caption":"The Couchbase Blog"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/15ea6a51d53d4739913c98d25a8d7e77","name":"Michael Minichino","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/ed87fc8ff8aedc56f9872fbd77382f29","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/03\/Screen-Shot-2022-03-28-at-12.40.06-PM.png","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/03\/Screen-Shot-2022-03-28-at-12.40.06-PM.png","caption":"Michael Minichino"},"url":"https:\/\/www.couchbase.com\/blog\/author\/michael-minichino\/"}]}},"authors":[{"term_id":9550,"user_id":81015,"is_guest":0,"slug":"michael-minichino","display_name":"Michael Minichino","avatar_url":{"url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/03\/Screen-Shot-2022-03-28-at-12.40.06-PM.png","url2x":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/03\/Screen-Shot-2022-03-28-at-12.40.06-PM.png"},"author_category":"","last_name":"Minichino","first_name":"Michael","job_title":"","user_url":"","description":"Michael Minichino is a Principal Solutions Engineer at Couchbase"}],"_links":{"self":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/13147","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/users\/81015"}],"replies":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/comments?post=13147"}],"version-history":[{"count":0,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/13147\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/media\/13151"}],"wp:attachment":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/media?parent=13147"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/categories?post=13147"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/tags?post=13147"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=13147"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}