---
title: writer
description: "DataSource.writer method in PySpark: Returns a DataSourceWriter instance for writing data."
canonical_url: https://docs.databricks.com/aws/en/pyspark/reference/classes/datasource/writer
---

# writer

Returns a `DataSourceWriter` instance for writing data.

The implementation is required for writable data sources.

*Added in Databricks Runtime 14.3 LTS*

## Syntax

```
writer(schema: StructType, overwrite: bool)
```

## Parameters

| Parameter   | Type       | Description                                                                           |
| ----------- | ---------- | ------------------------------------------------------------------------------------- |
| `schema`    | StructType | The schema of the data to be written.                                                 |
| `overwrite` | bool       | A flag indicating whether to overwrite existing data when writing to the data source. |

## Returns

`DataSourceWriter`

A writer instance for this data source.
