Automatically extract data from Microsoft SQL Server backup files (.bak) into Flatfile Workbooks for easy data review and processing.
.bak
). When a user uploads a .bak
file to a Flatfile Space, this plugin triggers a multi-step process. First, it uploads the backup file to a secure storage location. Then, it restores the backup to a Flatfile-hosted MSSQL database instance. After the database is restored and available, the plugin inspects its schema to identify all tables. Finally, it creates a read-only Flatfile Workbook where each database table is represented as a separate Sheet. This allows users to view and interact with data from large MSSQL databases directly within the Flatfile UI without needing to manually export data to CSV or Excel first. It is ideal for scenarios where the source of truth is an MSSQL database and users need to bring that data into the Flatfile ecosystem for review or processing.
file:created
events. If the uploaded file has a .bak
extension and is not for export, it initiates a job named ‘extract-foreign-mssql-db’. This job handles the entire workflow: creating a workbook, uploading the file to S3, restoring the database, polling for status, generating sheets from the database tables, and linking everything together. The process is entirely self-contained.
.bak
file uploads and manage the extraction process. This includes creating a corresponding job, restoring the database on a Flatfile-managed service, polling for its availability, generating Sheets from the database tables, and updating the Flatfile Workbook and File entities with the results.
Parameters:
(listener: FlatfileListener) => void
- A function that accepts a FlatfileListener instance and registers the necessary event handlerstry...catch
block within the job:ready
listener will catch the exception. It then updates the associated File status to ‘failed’ and fails the Job with a descriptive error message, making the failure visible in the Flatfile UI.
info
field. Common causes of failure could be a corrupted .bak
file or the database restore process exceeding the built-in timeout.
@flatfile/plugin-foreign-db-extractor
and @flatfile/listener
packages must be installedAGENT_INTERNAL_URL
and FLATFILE_BEARER_TOKEN
environment variables set, which are typically provided by the Flatfile platform.bak
extension. Other file types are ignoredjob:ready
listener. It uses a try...catch
block to wrap the entire extraction workflow. Upon catching an error, it uses the Flatfile API to update the status of the associated file and job to reflect the failure:
api.files.update(fileId, { status: 'failed' })
api.jobs.fail(jobId, { info: e.message })
Error
objects with specific messages that are propagated up to this central handler.