DEV Community

Yussy
Yussy

Posted on

Leveling up: Adding SQLite Persistence to my Rust Guessing Game

Introduction

I recently started my journey with Rust by following the famous "The Book" (The Rust Programming Language). After completing the Guessing Game tutorial, I decided to take it a step further by adding a way to record and save game results.

The Project

Initially, the game would forget everything once it closed. To fix this, I integrated SQLite so that every win is recorded permanently.

What I Added

  • Database Integration: Used the rusqlite crate to connect to a local SQLite database.
  • Persistence: The game now saves the player's name and the number of guesses.
  • SQL Queries: Implemented CREATE TABLE and INSERT statements within Rust.

Code & Reference

I built this by modifying the original tutorial code from "The Rust Programming Language."

What's Next?

This project helped me understand how Rust handles external crates and database connections.
As for what's next... I'm still brainstorming my next move! I might add a leaderboard to show the top scores, or perhaps explore building a web interface. I'm excited to see where my Rust journey takes me next.

Top comments (0)