This project is a basic practice application for interacting with databases using Go. It includes essential components to establish a connection, perform CRUD (Create, Read, Update, Delete) operations, and manage configuration files.
- Database Connection: Establish a secure and reliable connection to a database.
- CRUD Operations: Basic functionality to create, read, update, and delete records.
- Configuration Management: Read and parse settings from a JSON file.
- Go Module Support: Dependency management using Go modules.
learn_sql/
├── config.go // Loads configuration settings
├── config.json // JSON file with database configuration
├── connection_check.go // Script to test the database connection
├── crud.go // Handles CRUD operations
├── db.go // Core database connection logic
├── go.mod // Go module configuration
├── go.sum // Go module dependencies
├── main.go // Entry point of the application
- Go 1.18 or later
- A running database instance (e.g., MySQL, PostgreSQL)
- Properly configured
config.jsonfile
-
Clone the repository:
git clone <repository-url> cd learn_sql
-
Install dependencies:
go mod tidy
-
Configure your
config.jsonfile with the database credentials:{ "host": "localhost", "port": 3306, "user": "your-username", "password": "your-password", "dbname": "your-database-name" } -
Test the database connection:
go run connection_check.go
-
Run the application:
go run main.go
- Use
crud.goto interact with the database. - Modify
config.jsonfor different environments.
This project is licensed under the MIT License.