SQLITE3


Subject: SQLITE3
Hola a todos, estoy dando mis primeros pasos en SQLITE, Perdonen mi ignorancia, pero hay algo que no me cuadra.
Describo mi problema:
1.- Con un programa Purebasic, defino una base, defino una tabla, con solo un dato (VALOR).
Esto funciona bien, la base fue creada, la tabla también con el dato (VALOR) poblado con un valor 30), el programa hace un select * y muestra correctamente el contenido del campo VALOR.
2.- Luego ingreso a DB-BROWSER SQLITE, correctamente, hago open de la base de datos (BASE-RFF) me muestra correctamente su estructura, tabla
Frutas, con campo VALOR tipo FLOAT.
3.- hago BROWSE de la tabla frutas y me despliega correctamente el contenido de valor (30.0).
Hasta aqui todo bien, todo funciona.

Mi problema:
Me conecto a SQLITE para revisar con comandos:

SQLite version 3.30.1 2019-10-10 20:19:45
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> .open BASE-RFF
sqlite> .databases
main: E:\SQLITE3\BASE-RFF
sqlite> select * from Frutas;
Error: no such table: Frutas **** ERROR ****
sqlite>

NO entiendo por que no encuentra la tabla Frutas.
A continuación les envío:
Programa
Output de la ejecución.
;-------------------------------------------------------------------
;
; PROGRAMA :RFF-CREAR-BASE-Y-TABLA-CONPROGRAMA
; LENGUAGE :PUREBASIC
; AUTOR :RUBENfERNANDEZ
; CREADO :04-02-2020
;-------------------------------------------------------------------
;
UseSQLiteDatabase()

Enumeration
#DB = 0
EndEnumeration

Define databasefile.s = "BASE-RFF.db"

; Crear archivo de base de datos BASE-RFF (VACIO)


If CreateFile(#DB, databasefile)
Debug "0. OK - Archivo base de datos BASE-RFF creado"
CloseFile(#DB)
Else
Debug "1. !! No se pudo crear el archivo de base de datos" +
#CRLF$ + DatabaseError()
End
EndIf

; Abrimos la base de datos creada

If Not OpenDatabase(#DB, databasefile, "", "")
Debug "2.0 !! - Falla al abrir la Base BASE-RFF" +
#CRLF$ + DatabaseError()
End
Else
Debug "2. OK - Base BASE-RFF abierta"
EndIf

; Creamos una tabla en la base la llamaremos Frutas

If DatabaseUpdate(#DB, "CREATE TABLE Frutas(Valor FLOAT);")
Debug "3. OK - Table Frutas creada"
Else
Debug "3. !! - Falla al crear tabla Frutas" +
#CRLF$ + DatabaseError()

End
EndIf

; Insertar valores iniciales

If DatabaseUpdate(#DB, "INSERT INTO Frutas(Valor) VALUES(30);")
Debug "4. OK - INSERT valores : Ok"
Else
Debug "4. !! - INSERT de valores NO OK- STOP" +
#CRLF$ + DatabaseError()
End
EndIf

; Do an SQL Query with Prepared statement To simplify quote And avoid code injection
; https://en.wikipedia.org/wiki/Prepared_statement#PureBasic

SetDatabaseDouble(#DB, 0, My_Variabe)


; Leer valores

DatabaseQuery(#DB, "SELECT * FROM Frutas;")
While NextDatabaseRow(#DB)
Debug "5. OK - Contenido tabla Frutas:"
Debug "Valor: " + GetDatabaseDouble(#DB, 0)
Wend

CloseDatabase(#DB)

End

Output:
0. OK - Archivo base de datos BASE-RFF creado
2. OK - Base BASE-RFF abierta
3. OK - Table Frutas creada
4. OK - INSERT valores : Ok
5. OK - Contenido tabla Frutas:
Valor: 30



Ambiente:
WINDOWS 10.

Profile PM  
Subject: Re: SQLITE3
RFERNAN escribió:  
...
Ambiente:
WINDOWS 10.

Desconosco el uso de sqlite en windows 10 prueba hacerlo en linux con gambas que hay mucha informacion aquí en el foro.

Saludos.

Profile PM  

Page 1 of 1


  
You cannot post new topics
You cannot reply to topics
You cannot edit your posts
You cannot delete your posts
You cannot vote in polls
You cannot attach files
You can download files
You cannot post calendar events

   

This is a "Lo-Fi" version of our main content. To view the full version with more information, formatting and images, please click here.

Powered by Icy Phoenix based on phpBB
Design by DiDiDaDo

Generation Time: 0.1081s (PHP: -37% SQL: 137%)
SQL queries: 23 - Debug Off - GZIP Enabled