Skip to main content

Python

You can export the data generated by schemas or any type of data to python format

const userSchema = chaca.schema({
id: schemas.id.uuid(),
username: schemas.internet.userName(),
image: { type: schemas.image.people(), posibleNull: 50 },
posts: {
type: schemas.id.uuid(),
isArray: {
min: 1,
max: 5,
},
},
})

await userSchema.generateAndExport({
filaName: 'data',
format: 'python',
location: 'folder',
})

For example, if we have this schema, we generate 5 documents and export them in python format, we will obtain the following result

data = [
{
"id": "b3143282-25ac-42d1-a3e2-45613b37033e",
"username": "Valentina.",
"image": None,
"posts": ["537c813d-e173-4a9c-9714-5e3b16da22e9"],
},
{
"id": "6c3850c4-235c-44b8-ae0a-1ddae2044bab",
"username": "Adrian234",
"image": "https://images.unsplash.com/photo-1513682121497-80211f36a7d3?crop=entropy&cs=tinysrgb&fm=jpg&ixid=MnwzNTM2NjZ8MHwxfHNlYXJjaHw0fHxwZW9wbGV8ZW58MHx8fHwxNjY2OTcwODMw&ixlib=rb-4.0.3&q=80",
"posts": [
"2d2b4308-7684-4e08-a61e-ed82627c26ec",
"b954e823-822c-48a0-971b-4ba14b55244e",
],
},
{
"id": "42b85d68-601a-4082-804e-cc5ad58b3698",
"username": "Charles617",
"image": None,
"posts": [
"8ac77585-2917-446e-bdc9-5b7214a211a1",
"25c1e509-7cde-4a70-b279-79d1512a0c48",
"752e1da8-8144-4cbb-914e-15759b72085c",
],
},
{
"id": "0071594a-074d-4e92-a8e4-cc34ea34e93d",
"username": "Henry_",
"image": "https://images.pexels.com/photos/1709003/pexels-photo-1709003.jpeg",
"posts": [
"b374d99a-9746-4889-96ae-59ac0e55798b",
"23c6ac92-4ca8-42b3-972c-b8514384d9e6",
"a790de9e-ee95-4b5a-a181-e086cab4451a",
"d820d5b3-5589-4e36-8770-01820e79a8b2",
],
},
{
"id": "51ad7751-b9e6-42c9-b55c-e3eb04e9c1c5",
"username": "Caleb_",
"image": "https://images.unsplash.com/photo-1481437642641-2f0ae875f836?crop=entropy&cs=tinysrgb&fm=jpg&ixid=MnwzNTM2NjZ8MHwxfHNlYXJjaHw0N3x8cGVvcGxlfGVufDB8fHx8MTY2Njk3MDgzMw&ixlib=rb-4.0.3&q=80",
"posts": [
"c478213c-71de-4d11-8d2b-c8953c221750",
"628bb483-4b4b-4e6e-b0c4-b2a0c462895c",
"5972dee0-6d7b-46be-97d0-b0e69476e3e6",
],
},
]