feat: added functionality for insert and select

This commit is contained in:
2026-07-23 23:40:10 +05:30
parent c719848c25
commit e625b29d3c
2 changed files with 7 additions and 6 deletions
+2 -1
View File
@@ -33,9 +33,10 @@ func Run() {
switch statement.PrepareStatements(inputBuffer) { switch statement.PrepareStatements(inputBuffer) {
case PrepareSuccess: case PrepareSuccess:
//todo //todo
case PrepareSyntaxError:
fmt.Println("Syntax error, could not parse statement")
case PrepareUnrecognised: case PrepareUnrecognised:
fmt.Printf("Unrecognised keyword at the start of '%s'.\n", inputBuffer.Buffer) fmt.Printf("Unrecognised keyword at the start of '%s'.\n", inputBuffer.Buffer)
continue
} }
switch statement.ExecuteStatement(table) { switch statement.ExecuteStatement(table) {
+5 -5
View File
@@ -151,11 +151,11 @@ func DoMetaCommands(inputBuffer *InputBuffer) MetaCommandResults {
func (statement *Statement) PrepareStatements(inputBuffer *InputBuffer) PrepareResults { func (statement *Statement) PrepareStatements(inputBuffer *InputBuffer) PrepareResults {
if strings.HasPrefix(inputBuffer.Buffer, "insert") { if strings.HasPrefix(inputBuffer.Buffer, "insert") {
argsAssigned, err := fmt.Sscanf(inputBuffer.Buffer, "insert %d %s %s", &statement.row.id, &statement.row.username, &statement.row.email) argsAssigned, err := fmt.Sscanf(inputBuffer.Buffer, "insert %d %s %s", &statement.row.id, &statement.row.username, &statement.row.email)
if err != nil { // if err != nil {
fmt.Println("error parsing insert statement") // fmt.Println("error parsing insert statement")
fmt.Println(err.Error()) // fmt.Println(err.Error())
} // }
if argsAssigned > 3 { if err != nil || argsAssigned > 3 {
return PrepareSyntaxError return PrepareSyntaxError
} }
statement.stype = StatementInsert statement.stype = StatementInsert