SQLiteREST 1.1.2
dotnet tool install --global SQLiteREST --version 1.1.2
dotnet new tool-manifest
dotnet tool install --local SQLiteREST --version 1.1.2
#tool dotnet:?package=SQLiteREST&version=1.1.2
nuke :add-package SQLiteREST --version 1.1.2
SQLiteREST
SQLiteREST is a .NET tool that automatically creates a RESTful API from your SQLite database. Inspired by projects like PostgREST, SQLiteREST allows you to quickly serve your SQLite database over HTTP, making it easy to prototype applications or build simple backends.
Features
- Automatic RESTful API generation from SQLite database
- Supports basic CRUD operations (Create, Read, Update, Delete)
- Dynamic routing based on table names
- Easy to install and use as a .NET tool
- Configurable database connection
- Swagger UI for API documentation and testing
Prerequisites
Before you can use SQLiteREST, you need to set up your environment. Follow these steps:
1. Install .NET SDK
- Visit the official .NET download page: https://dotnet.microsoft.com/download
- Download and install the .NET 8.0 SDK or later for your operating system.
- After installation, open a command prompt or terminal and verify the installation by running:
This should display the version of .NET SDK you installed.dotnet --version
2. Install SQLite
- Visit the SQLite download page: https://www.sqlite.org/download.html
- Download the appropriate version for your operating system.
- Follow the installation instructions for your OS.
3. Create a Sample SQLite Database
- Open a command prompt or terminal.
- Navigate to the directory where you want to create your database.
- Run the following command to create a new SQLite database:
sqlite3 sample.db - You're now in the SQLite prompt. Create a sample table:
CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, email TEXT); - Insert some sample data:
INSERT INTO users (name, email) VALUES ('John Doe', 'john@example.com'); INSERT INTO users (name, email) VALUES ('Jane Smith', 'jane@example.com'); - Exit the SQLite prompt by typing
.quitand pressing Enter.
Installation
After setting up your environment and creating a sample database, you can install SQLiteREST:
dotnet tool install --global SQLiteREST
If you're using an older version of .NET, you might need to add the --version flag to specify the correct version of SQLiteREST that matches your .NET SDK version.
Usage
To start the SQLiteREST server, navigate to the directory containing your SQLite database file and run:
sqliterest --database sample.db
This will start the server, and you can access your API at http://localhost:5000.
API Endpoints
SQLiteREST automatically generates the following endpoints for each table in your database:
GET /db/{table}: Retrieve all records from the tableGET /db/{table}/{id}: Retrieve a specific record by IDPOST /db/{table}: Create a new recordPUT /db/{table}/{id}: Update an existing recordDELETE /db/{table}/{id}: Delete a record
For example, with our sample database:
GET /db/users: Retrieve all usersGET /db/users/1: Retrieve the user with ID 1POST /db/users: Create a new userPUT /db/users/1: Update the user with ID 1DELETE /db/users/1: Delete the user with ID 1
Query Parameters
You can use query parameters to filter, sort, and paginate your results:
?filter=column:operator:value: Filter results (e.g.,?filter=name:eq:John Doe)?sort=column: Sort results (use-columnfor descending order)?limit=n: Limit the number of returned results?offset=n: Offset the results for pagination
Configuration
You can configure SQLiteREST using command-line options or a configuration file. Run sqliterest --help to see all available options.
Security
By default, SQLiteREST does not include authentication or authorization. It's recommended to use this tool only for development or in secure environments. For production use, consider implementing proper security measures.
Contributing
Contributions to SQLiteREST are welcome! Please feel free to submit a Pull Request.
License
SQLiteREST is open-source software licensed under the MIT license.
Troubleshooting
If you encounter any issues during setup or usage:
- Ensure your .NET SDK version is compatible with SQLiteREST.
- Check that SQLite is correctly installed and accessible from the command line.
- Verify that your database file exists and is in the correct location.
- Make sure you have the necessary permissions to read/write to the database file.
If problems persist, please open an issue on the GitHub repository with details about your environment and the error you're encountering.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
This package has no dependencies.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.1.2 | 219 | 10/2/2024 |