Skip to content

feat: add support for sql-based databases#2506

Draft
pkuwwt wants to merge 17 commits intofilebrowser:masterfrom
pkuwwt:psql
Draft

feat: add support for sql-based databases#2506
pkuwwt wants to merge 17 commits intofilebrowser:masterfrom
pkuwwt:psql

Conversation

@pkuwwt
Copy link
Copy Markdown

@pkuwwt pkuwwt commented Jun 17, 2023

Description
Add sql support in addition to bolt, including sqlite3, postgres, mysql.

Most code are in storage/sql, except a few lines in cmd/root.go and cmd/utils.go.

Usage

filebrowser -d sqlite3://test.db
filebrowser -d 'postgres://user:[email protected]:5432/postgres?sslmode=disable'

Reason
Bolt is a relative non-mainstream choice for storage. When someone use filebrowser as a component of a project, he/she will need a centralized storage server, e.g. postgres, mysql, other than bolt.

@pkuwwt pkuwwt requested a review from o1egl as a code owner June 17, 2023 14:02
@github-actions
Copy link
Copy Markdown

This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the Stale label Jul 18, 2023
@o1egl o1egl added wip and removed Stale labels Jul 22, 2023
@o1egl o1egl force-pushed the master branch 2 times, most recently from 813c2e9 to 66dfbb3 Compare July 28, 2023 22:27
@pkuwwt
Copy link
Copy Markdown
Author

pkuwwt commented Dec 21, 2023

conflicts resolved @o1egl

@sevmonster
Copy link
Copy Markdown

sevmonster commented Feb 6, 2024

Can any effort be put into merging this? Filebrowser CLI cannot be used inside container or while it's running in general, because of the exclusive database lock. This is seriously inconvenient. I am forced at this point to either kill filebrowser every time I want to run a CLI command, or build this PR for use in production. This also affects automation and makes it difficult to programmatically add users (for example) based on other input. I would use the API but it is not documented and seems fiddly to use, #2551.

@sevmonster
Copy link
Copy Markdown

sevmonster commented Feb 7, 2024

I built this and merged with master. Works with Postgres, but I've found some issues.

  1. The github.com/mattn/go-sqlite3 library isn't being updated anymore, and the last release is from 2022. It didn't build successfully on my machine, and I had to update it to the latest Git commit v0.0.0-20240202170028-6ee3e6746e6b to build.
  2. AuthMethod of type proxy does not seem to work. It either isn't grabbing the header from the auther row, or is not being properly substituted in the SQL statement. I am investigating.
    The statement being run:
    SELECT id,username,password,scope,locale,lockpassword,viewmode,perm,commands,sorting,rules,hidedotfiles,dateformat,singleclick FROM "fb_users" WHERE username=''
    As a consequence of this, I see the login page since it is shown when the user either doesn't exist or isn't authed properly, as noted in many other issues.
    Actually, this seems to be an upstream bug. Proxy auth doesn't work #2995
  3. config set attempts to insert already existing rows, like Root and Socket. I had to delete all the offending rows to allow it to re-insert them in order to use the command and add new values.

@pkuwwt
Copy link
Copy Markdown
Author

pkuwwt commented Feb 9, 2024

@sevmonster config set problem solved by insert-or-update

@hacdias hacdias removed the wip label Jun 13, 2025
@hacdias hacdias removed the request for review from o1egl November 14, 2025 15:31
@hacdias hacdias changed the title Psql feat: add support for sql-based databases Nov 14, 2025
@hacdias
Copy link
Copy Markdown
Member

hacdias commented Nov 14, 2025

Hey! Thanks for all the effort put into this. I do agree that this could be useful, but it's quite a large change and effort to maintain. As such, I am parking this now, but leaving the PR open.

@hacdias hacdias requested a review from a team November 14, 2025 16:46
@hacdias hacdias marked this pull request as draft March 11, 2026 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants