Monitor Database Files with OBS Advanced Scene Switcher

Integrating local database monitoring into OBS Studio allows you to automate overlays, alerts, and scene transitions based on real-time data updates. This guide provides a direct, step-by-step walkthrough on how to configure the Advanced Scene Switcher plugin to monitor changes in a local database file—such as a flat-file database (JSON/CSV) or an SQLite database—to trigger automated alerts during your live stream.

Step 1: Prepare Your Database Output

Because Advanced Scene Switcher cannot natively parse raw, binary relational databases (like a live SQL server), you must output your database changes to a readable flat file.

Step 2: Open Advanced Scene Switcher

  1. Launch OBS Studio.
  2. Navigate to the top menu and select Tools > Advanced Scene Switcher.
  3. Ensure the plugin is running by navigating to the General tab and clicking Start (if it is not already active).

Step 3: Create the File Monitoring Macro

To detect changes in your exported database file, you need to create a conditional macro: 1. Navigate to the Macros tab. 2. Click the + (plus) icon at the bottom of the screen to create a new macro. Name it something descriptive, such as “Database Alert Trigger”. 3. In the condition section (the “If” statement), click the first dropdown menu and select File. 4. Click Browse and locate your local database output file (the .txt, .csv, or .json file). 5. Choose your evaluation criteria: * Select “has changed” if you want to trigger an alert every time the database updates. * Select “contains” (and type a specific keyword) if you only want to trigger the alert when a specific value is written to the file.

Step 4: Configure the Alert Action

Now, define what OBS Studio should do when the file change is detected: 1. In the action section (the “Then” statement), click the dropdown and select your desired action. * To show a graphic or text: Select Source visibility, choose your scene and source, and set it to Show. * To play a sound: Select Media integration or toggle an audio source. 2. Add a delay to hide the alert after it plays. Click the + icon under the actions list to add a secondary action. 3. Select Wait, and enter your desired duration (e.g., 00:00:05 for 5 seconds). 4. Add a third action, select Source visibility, choose the same alert source, and set it to Hide.

Step 5: Querying SQLite Directly (Alternative Method)

If you prefer not to use an external script to write to a text file, you can query a local SQLite database directly using Advanced Scene Switcher’s system commands: 1. Go to the System tab in Advanced Scene Switcher. 2. Enable the system command feature and set up a command to run periodically (e.g., every 3 seconds). 3. Enter a command that queries your SQLite database and outputs the result to a text file. For example:
sqlite3 path/to/database.db "SELECT alert_text FROM alerts ORDER BY id DESC LIMIT 1;" > path/to/output.txt 4. Follow Step 3 and Step 4 to monitor the generated output.txt file.

Step 6: Test and Enable

  1. Save your macro.
  2. Manually write a new entry or update your local database file.
  3. Observe the “Macros” tab in Advanced Scene Switcher; the condition should highlight green, and your OBS sources should toggle automatically.