Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/akshitvadodariya1201/rust-with-postgresql
This project is a Rust application that interacts with a PostgreSQL database to manage authors and books. It demonstrates basic CRUD operations using the postgres crate.
https://github.com/akshitvadodariya1201/rust-with-postgresql
cargo docker docker-compose postgresql rust sql
Last synced: 6 days ago
JSON representation
This project is a Rust application that interacts with a PostgreSQL database to manage authors and books. It demonstrates basic CRUD operations using the postgres crate.
- Host: GitHub
- URL: https://github.com/akshitvadodariya1201/rust-with-postgresql
- Owner: AkshitVadodariya1201
- Created: 2024-07-04T13:15:11.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-07-24T06:28:40.000Z (6 months ago)
- Last Synced: 2024-11-09T15:30:17.653Z (2 months ago)
- Topics: cargo, docker, docker-compose, postgresql, rust, sql
- Language: Rust
- Homepage:
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# DB-Data Project
## Overview
This project is a Rust application that interacts with a PostgreSQL database to manage authors and books. It demonstrates basic CRUD operations using the `postgres` crate.
## Prerequisites
- Rust and Cargo (See [Rust Installation](https://www.rust-lang.org/tools/install))
- Docker and Docker Compose (See [Docker Installation](https://docs.docker.com/get-docker/))
- PostgreSQL client (Optional, for direct database interaction)## Setup
1. Clone the repository:
```sh
git clone
cd
```2. Start the PostgreSQL database using Docker Compose:
```sh
docker-compose up -d
```This command starts a PostgreSQL instance and an Adminer instance for database management accessible at `http://localhost:8080`.
3. Run the application:
```sh
cd db-data
cargo run
```This command compiles the Rust application and executes it, performing the defined database operations.
## Structure
- `src/main.rs`: Contains the main application logic for interacting with the PostgreSQL database.
- `Cargo.toml`: Contains the project metadata and dependencies.
- `docker-compose.yml`: Contains the configuration for the PostgreSQL and Adminer services.## Database Schema
The database schema consists of two tables:
- `authors`: Contains the author information with the following columns:
- `id`: Unique identifier for the author.
- `name`: Name of the author.
- `country`: Country of the author.
- `books`: Contains the book information with the following columns:
- `id`: Unique identifier for the book.
- `title`: Title of the book.
- `author_id`: Foreign key referencing the `authors` table.
## Usage
The application provides a command-line interface (CLI) to interact with the database. The available commands are:
- `list-authors`: List all authors in the database.
- `create-author `: Create a new author with the given name.
- `delete-author `: Delete the author with the given ID.
- `list-books`: List all books in the database.
- `create-book `: Create a new book with the given title and author ID.
- `delete-book `: Delete the book with the given ID.
- `help`: Display the list of available commands.
- `exit`: Exit the application.
## LicenseThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.