Locally 2 bench data share

I have setup 2 frappe benches locally. And I have to create an entry in one bench and sync it with the other bench. Is this possible?

bench A - create item inside form add butom sync item in bench B
bench B - sync item bench A

@Manish_Kumar Do you want to sync data from one site to another?

yes one site to another bench site

yes another site to another bench

Hi,

You can use the ERPNext Event Streaming. You can check this documentation for the details: Event Streaming (erpnext.com)

Thanks,

Divyesh Mangroliya

Hy @Manish_Kumar
You see and understand this code. In this code, customers were synced from one site to another. I hope this helps you

@frappe.whitelist()
def sync_customer():
	url = "http://test.com:8000/api/resource/Customer"
	headers = {"Authorization": "Token 263f977fc8d0515:288654b3bdfdf5f"}
	response = requests.get(url, headers=headers)


	if response.status_code == 200:
		data_dict = response.json()
		for customer_data in data_dict.get('data', []):
			create_customer(customer_data)
			# print(f"Created customer: {customer_data['name']}")
	else:
		pass
		# print(f"Failed to fetch data. Status code: {response.status_code}")


def create_customer(data):
	cust_data = data['name']
	cust_get = frappe.db.get_list('Customer',filters={'customer_name': cust_data },fields=['customer_name'], as_list=True)
	if not cust_get:
		customer = frappe.get_doc({
		"doctype": "Customer",  # Assuming the doctype for customers in ERPNext is "Customer"
		"customer_name": data["name"],  # Use the "name" from the data
		})
		customer.insert()
	else:
		pass	

Thank You!

thank you i try this code

bench A insert customer bench bhi sync on insert realtime

@Manish_Kumar yas

like bench A insert customer post api hit bench B customer sync on hit snd crate customer in benchh A