With this code I get the good results. But what else can we do? and especially using OPEN PIPE for the output file?
Thank you for your remarks.
Best regards
Code: Select all
' Executer une requête sql depuis FreeBasic et Linux"
' On prend Sqlite3 à qui l'on passe les ordres sql
Const crlf =Chr(13)&Chr(10)
dim as string codesql,result
' Ordres sql
codesql=".mode column "& crlf
codesql=codesql &"select tit,nom,prenom"& crlf
codesql=codesql &"from contacts" & crlf
codesql=codesql &"order by nom,prenom" & crlf
Print "code :"
Print codesql
Open "ordre.sql" For Output As #1
Print #1,codesql
Close #1
Print
Open Pipe "sqlite3 BaseTest.sqlite < ordre.sql" For Input As #2
While not eof(2)
Line Input #2,result
Print result
Wend
Close #1
code :
.mode column
select tit,nom,prenom
from contacts
order by nom,prenom
2 Curie Marie
1 Lincoln Abraham
1 Schweitzer Albert
1 Tolstoï Léon