REVO5500 SQLite browser @ p connID On Openstack
if the short name of this stack is "SQLite browser" then
set the connID of this stack to empty
svuotatutto
end if
end Openstack
on svuotatutto
#carta Structure
set the text of field tabellestrut of card "Structure" to empty
set the text of field tabelle of card "Structure" to empty
set thetext of field "nometabella" of card "Structure" to empty
#Carta Data
set the text of button tabelle of card "Data" to empty
set the dgData of group "tabellona" of card "Data" to empty
set the dgProp["columns"] of group "tabellona" of card "Data" to empty
#Carta SQL
set the text of field "query" of card "SQL" to empty
set the text of field "risultato" of card "SQL" to empty
set the text of field "errori" of card "SQL" to empty
end svuotatutto
on databaseConnect miofile
svuotatutto
#facciamo un backup
put "binfile:" & miofile into miofileingresso
put miofileingresso & ".bak" into miofileuscita
get URL miofileingresso
put it into URL miofileuscita
## The database must be in a writeable location
put miofile into tDatabasePath
## Open a connection to the database
## If the database does not already exist it will be created
put revOpenDatabase("sqlite", tDatabasePath, , , , ) into tDatabaseID
## Store the database id so other handlers can access it
set "connID" of this stack to tDatabaseID
aggiornatutto
end databaseConnect
on aggiornatutto
#connessione
put the connID of this stack into connID
if connID is not empty then
#revDatabaseTableNames(connID)
#answer connID
put "SELECT name FROM sqlite_master WHERE type = 'table'" into tSQL
put revDataFromQuery(tab,return,connID,tSQL) into tRecords
set the text of field tabelle of card "Structure" to tRecords
set the text of button tabelle of card "Data" to tRecords
end if
end aggiornatutto
W Tahoma
Menubar 1 cRevStandaloneSettings /scriptLibraries Internet
Geometry
Printing
Linux x64 falseMacOSX true OSX,name SQLite browserUNIX,fileSelector trueWindows trueandroid,signing Sign for development onlyWindows,LegalCopyright #2014 All rights reserved worldwideUNIX,pageSetup trueSolaris SPARC falseOSX,documentType Linux trueios falseinclusions searchWindows,documenticonFile gC:/Programmi/RunRev/LiveCode Community 6.5.1/Runtime/Windows/x86-32/Support/Sample Icons/genericdoc.ico
answerDialog trueOSX,documentExtension Windows,FileDescription "SQLite browser 1.0.0.0 for WindowsOSX,longVersion SQLite browser 1.0.0.0UNIX,printerChooser trueOSX,copyright #2014 All rights reserved worldwideandroid falseOSX,identifier com..sqlitebrowsername SQLite browserSolaris Intel falseOSX,shortVersion 1.0.0.0Windows,fileversion1 1Windows,fileversion2 0Windows,productversion1 1Windows,fileversion3 0Windows,productversion2 0Windows,fileversion4 0Windows,productversion3 0cursors falseWindows,productversion4 0 OSX,info SQLite browser Version 1.0.0.0errorDialog falseMacOSX PowerPC-32 false
Windows,UUID $a6716f9c-5896-4a25-a983-dace6f25dceb
askDialog trueWindows,iconFile gC:/Programmi/RunRev/LiveCode Community 6.5.1/Runtime/Windows/x86-32/Support/Sample Icons/genericapp.icoOSX,signature ????Windows,ProductName SQLite browserdefaultBuildFolder =C:/Documents and Settings/max/Documenti/Dropbox/SQLiteManagerUNIX,colorChooser trueMacOSX x86-32 falseWindows,companyname cRevOnline id 758 cREVGeometryCache stackID 32979 cREVGeneral scripteditorvscroll 462breakpointconditions scripteditorselection 1536breakpoints breakpointstates stackfileversion 5.5AlreadyHidden false
Structure P on opencard
#revupdateGeometry
aggiornatutto
set the text of field "tabellestrut" to empty
set the text of field "nometabella" to empty
end opencard
: cREVGeneral scripteditorvscroll 0scripteditorselection 16 cREVGeometryCacheIDs 1389801740880 11411389801699614 11391389958437854 36741389958437855 36751389802808930 11481389958437856 36761389802786692 11451389958437857 36771389956250962 29851389801651691 11361389801629853 1137 cREVGeometrycache total 11order F1389801651691
1389802786692
1389802808930
1389801740880
1389956250962
q s u y | Z ~ Data P=On opencard
revupdateGeometry
aggiornatutto
aggiornatabella
end opencard
on aggiornatabella
put the label of button tabelle into curtab
#puliamo la tabella
set the dgData of group "tabellona" to empty
#connessione
put the connID of this stack into connID
if connID is not empty then
#recuperiamo le colonne
put revDatabaseColumnNames(connID, curtab ) into titoli
replace "," with return in titoli
#aggiungiamo il rowid della riga per rendere unica la selezione
put "rowid" & return before titoli
set the dgProp["columns"] of group "tabellona" to titoli
#recuperiamo i dati
put "SELECT rowid,* FROM " & curtab into tSQL
##old way to populate datagrid
##put revDataFromQuery(tab,return,connID,tSQL) into tRecords
##set the dgtext of group "tabellona" to tRecords
##new way
put revQueryDatabase( connID, tSQL) into theCursor
ConvertSQLCursorToArray theCursor, theDataGridArray
set the dgData of group "tabellona" to theDataGridArray
revCloseCursor theCursor
##
set the dgColumnWidth["rowid"] of group "tabellona" to 30
set the dgColumnTooltip["rowid"] of group "tabellona" to "This is internal, it doesn't exist"
set the dgColumnLabel["rowid"] of group "tabellona" to " " #se metti empty, usa il nome
end if
end aggiornatabella
command ConvertSQLCursorToArray pCursor, @pOutArrayA
local i
local theFields
local theError
## Get the names of all the columns in the database cursor
put revDatabaseColumnNames(pCursor) into theFields
#bug corrected
if theFields begins with "revdberr," then
put item 2 to -1 of theFields into theError
end if
if theError is empty then
put 0 into i
## Loop through all rows in cursor
repeat until revQueryIsAtEnd(pCursor)
add 1 to i
## Move all fields in row into next dimension of the array
put 1 into mycont
repeat for each item theField in theFields
#note that SQLite has an interna rowid, but if a ID with the same type is present,
#the real name is ID, so we have to assure to name rowid the array column
#otherwise the rowid colum will be empty on the datagrid
if mycont is 1 then
put revDatabaseColumnNamed(pCursor, theField) into pOutArrayA[i]["rowid"]
else
put revDatabaseColumnNamed(pCursor, theField) into pOutArrayA[i][ theField ]
end if
add 1 to mycont
end repeat
revMoveToNextRecord pCursor
end repeat
end if
return theError
end ConvertSQLCursorToArray
? cREVGeneral scripteditorvscroll 160scripteditorselection 1131 cREVGeometryCacheIDs 1389879079568 11651389879079570 11671389879079569 11661389879079571 11681389879079572 11691389879079573 11701389879079574 11721389879079575 11731389879079576 11741389879079577 11751392029867825 134931389958437854 36741389958437855 36751390322943241 109441389958437856 36761389958437857 36771389879078235 11531389879077893 11541389879077894 11611389879079559 11551389879079560 11561389879079561 11571389879077895 11711389801651691 11361389879079562 11581389879079563 11591389879079564 11601389879079565 11621389879079566 11631389879086263 11771389879079567 11641389801629853 1137 cREVGeometrycache total 32order 81389801651691
1389879078235
1390322943241
1392029867825
q Z * 4 SQL P /on opencard
revupdateGeometry
end opencard
[ cREVGeneral scripteditorvscroll 0 cREVGeometryCacheIDs
1389887094078 18491389958437854 36741389958437855 36751389958437856 36761389887267189 18581389958437857 36771389887230931 18521389887269101 18591389887252055 18551389887413408 18611389801651691 11361389887051154 18471389801629853 1137 cREVGeometrycache total 13order q 7 9 < ? B C E Z q @ i y cREVGeneral scripteditorvscroll 0revUniqueID
1389801629853scripteditorselection 0 p Tab Menu u on menuPick pItemName
go card pItemName -- it is the name of the tab, which in turn will also be the name of the appropriate card
end menuPick
$ Structure
Data
SQL
cREVGeometry Master,scaleBottomObjectSide BottomMaster,scaleBottomscaleBottom trueMaster,movehDistance falseMaster,scaleRightscaleBottom trueMaster trueMaster,scaleTopObjectRef cardMaster,scaleLeftObjectRef cardMaster,scaleBottomObjectRef cardMaster,scaleBottomAbsolute trueMaster,scaleBottom trueMaster,scaleTopObjectSide TopMaster,scaleLeftObjectSide LeftMaster,expectedRect 4,52,524,572Master,scalebottomDistance 259Master,movevDistance falseMaster,scaleRightAbsolute trueMaster,scaleRight trueMaster,scalerightDistance 461Master,scaleTopAbsolute trueMaster,scaleLeftAbsolute trueMaster,scaleRightObjectSide RightMaster,scaleRightObjectRef cardMaster,scaleTop trueMaster,scaleLeft trueMaster,cardRanking 4Master,scaleleftDistance 4Master,scaletopDistance 36 cREVGeneral scripteditorvscroll 0revUniqueID
1389801651691scripteditorselection 141
s Label Field P d }
cREVTable currentview Tables: cREVGeneral revUniqueID
1389801699614 Tables:
u TitoloTabellaStrutture N l {
cREVGeometry Master,movehDistance -0.353887Master,scaleRightscaleBottom trueMaster trueMaster,scaleleftObjectRef
1389802786692Master,moveHObjectRef cardMaster,scaleleftObjectSide rightMaster,expectedRect 217,78,310,106Master,scalebottomDistance Master,movevDistance falseMaster,dontClipText falseMaster,moveHObjectSide rightMaster,scaleRightAbsolute falseMaster,scaleRight trueMaster,scalerightDistance -0.243968Master,scaleRightObjectRef cardMaster,scaleRightObjectSide RightMaster,scaleleftAbsolute trueMaster,scaleleft trueMaster,cardRanking 1Master,scaleleftDistance 39Master,moveHAbsolute falseMaster,scaletopDistance
Master,moveH false
cREVTable currentview Table structure: cREVGeneral revUniqueID
1389801740880 Table structure:
y tabelle )pon mouseUp
put the connID of this stack into connID
put the selectedtext of me into temp
set the text of field "nometabella" to temp
put "PRAGMA table_info(" & temp & ")" into tSQL
put revDataFromQuery(tab,return,connID,tSQL) into tRecords
put empty into temp
set the itemdel to tab
repeat for each line tline in tRecords
put "" after temp
put item 2 of tline after temp
put " - " after temp
put item 3 of tline after temp
if item 4 of tline <> 0 then
put "(not null)" after temp
end if
if item 5 of tline is not empty then
put " DEFAULT VALUE " & item 5 of tline & " " after temp
end if
if item 6 of tline <> 0 then
put " PRIMARY KEY" after temp
end if
put "
" & return after temp
end repeat
set the htmltext of field tabellestrut to temp
end mouseUp
h x
cREVGeometry Master,scaleBottomObjectSide BottomMaster,movehDistance falseMaster,scaleRightscaleBottom trueMaster trueMaster,scaleLeftObjectRef cardMaster,scaleBottomObjectRef cardMaster,scaleBottomAbsolute trueMaster,scaleBottom trueMaster,scaleLeftObjectSide LeftMaster,expectedRect 12,104,224,554Master,scalebottomDistance -17Master,movevDistance falseMaster,scaleRightAbsolute falseMaster,scaleRight trueMaster,scalerightDistance -0.565684Master,scaleRightObjectRef cardMaster,scaleRightObjectSide RightMaster,scaleLeftAbsolute trueMaster,scaleLeft trueMaster,cardRanking 3Master,scaleleftDistance 12Master,scaletopDistance cREVGeneral scripteditorvscroll 0revUniqueID
1389802786692scripteditorselection 58 z ` @ i
j a @
}
|
tabellestrut )` g x
cREVGeometry Master,scaleBottomObjectSide BottomMaster,movehDistance falseMaster trueMaster,scaleleftObjectRef
1389802786692Master,scaleBottomObjectRef cardMaster,scaleBottomAbsolute trueMaster,scaleBottom trueMaster,scaleleftObjectSide rightMaster,expectedRect 262,103,489,553Master,scalebottomDistance -18Master,movevDistance falseMaster,scaleRightAbsolute trueMaster,scaleRight trueMaster,scalerightDistance -26Master,scaleleftAbsolute trueMaster,scaleRightObjectSide RightMaster,scaleRightObjectRef cardMaster,scaleleft trueMaster,cardRanking 2Master,scaleleftDistance 38Master,scaletopDistance cREVGeneral revUniqueID
1389802808930 } ` @ h
j a @
{
tabellona h @@@@@@ j on CloseFieldEditor pFieldEditor
put the dgColumn of the target into theColumnBeingEdited
put the text of pFieldEditor into theNewText
## Get the unique id of the row in the database we want to edit
#put GetDataOfIndex(the dgIndex of the target, "id") into theRowID
#SaveDataToDatabase theTable, theRowID, theColumnBeingEdited, theNewText
## Update dgData.
## Setting dgDataOfIndex will refresh the data grid display as well as update dgData
put the dgDataOfIndex[ the dgIndex of the target] of me into theDataA
put theNewText into theDataA[theColumnBeingEdited]
set the dgDataOfIndex[the dgIndex of the target] of me to theDataA
#now custom commands
#answer theNewText
put theDataA["rowid"] into rowid
#connessione
put the connID of this stack into connID
#costruiamo la query
put the label of button "tabelle" into nometab
#controllo apostrofi
replace "'" with "''" in theNewText
put "UPDATE " & nometab & " SET " & theColumnBeingEdited & "='" & theNewText &"' WHERE rowid=" & rowid into tSQL
##answer tSQL
revExecuteSQL connID,tSQL
end CloseFieldEditor
revDataGridLibrary 8
cREVGeometry Master,scaleBottomObjectSide BottomMaster,movehDistance falseMaster trueMaster,scaleLeftObjectRef cardMaster,scaleBottomObjectRef cardMaster,scaleBottomAbsolute trueMaster,scaleBottom trueMaster,scaleLeftObjectSide LeftMaster,movevDistance falseMaster,scalebottomDistance -2Master,expectedRect 16,100,500,556Master,scaleRightAbsolute trueMaster,scaleRight trueMaster,scalerightDistance -3Master,scaleRightObjectRef cardMaster,scaleRightObjectSide RightMaster,scaleLeftAbsolute trueMaster,scaleLeft trueMaster,cardRanking 3Master,scaletopDistance Master,scaleleftDistance 12 cGlx2TimeStamp checksum ُ B~ dgCache dgProps &scrollbar corner offset 0scrollbar width autoauto hilite true
corner color 232,232,232show vscrollbar trueshow hscrollbar truecolumn margins dim on focusOut true
row template Jgroup id 1006 of card id 1005 of stack "Data Grid Templates 1389879077846" data can be represented as text true!scroll when hscrollbar is hidden falseheader background color 219,219,219
188,188,188allow column resizing truecolumn widths header margins header divider threed color 227,227,227
control type Data Gridcolumn divider color 217,217,217sort by column style Tablecolumns fixed row height truealternate row colors trueshow header truecolumn properties scroll selections into view truebackground color multiple lines falsepersistent data falseallow editing trueheader background hilite color 194,207,221
125,147,148
row color row height 21!scroll when vscrollbar is hidden falseheader divider color 168,168,168alternate row color cache controls false
hilite color cREVGeneral scripteditorvscroll 0revUniqueID
1389879078235scripteditorselection 1137 dgTrackDragDrop ` s ( revDataGridLibrary cGlx2TimeStamp checksum ُ B~ cREVGeneral revUniqueID
1389879077893 dgAlternatingRows d A *
z T V * cGlx2TimeStamp checksum cREVGeneral revUniqueID
1389879079559 dgEventCatcher `@*
k cGlx2TimeStamp checksum cREVGeneral revUniqueID
1389879079560 ~
dgBackground k@
k ] cGlx2TimeStamp checksum ُ B~ cREVGeneral revUniqueID
1389879079561 dgAlternatingRowsMask h
~_ cGlx2TimeStamp checksum cREVGeneral revUniqueID
1389879079562 dgAlternatingRows K@
~_ _ cGlx2TimeStamp checksum cREVGeneral revUniqueID
1389879079563 dgListMask i
~_ cGlx2TimeStamp checksum cREVGeneral revUniqueID
1389879079564
dgHighlights i cGlx2TimeStamp checksum cREVGeneral revUniqueID
1389879077894 dgList i
~Y_ $ revDataGridLibrary cGlx2TimeStamp checksum ُ B~ cREVGeneral revUniqueID
1389879079565 dgDividers i ~ cGlx2TimeStamp checksum cREVGeneral revUniqueID
1389879079566 dgDropIndicator q vZ1 $ hrevDataGridLibrary
cGlx2TimeStamp checksum ُ B~ cREVGeneral revUniqueID
1389879079567 dgOval [D vZ M h cGlx2TimeStamp checksum cREVGeneral revUniqueID
1389879079568 dgLine [ }^* `` cGlx2TimeStamp checksum cREVGeneral revUniqueID
1389879079569 dgHeaderComponents i
k cGlx2TimeStamp checksum cREVGeneral revUniqueID
1389879079570
dgHeaderMask h
k $ revDataGridLibrary cGlx2TimeStamp checksum ُ B~ cREVGeneral revUniqueID
1389879079571
dgBackground K@ @@@@@@
kY ! 16 k6 ~ k Y cGlx2TimeStamp checksum cREVGeneral revUniqueID
1389879079572 dgHeader i 5 k $ *revDataGridLibrary cGlx2TimeStamp checksum cREVGeneral revUniqueID
1389879079573 dgHeaderBottomBorder K @@@@@@
}Y cGlx2TimeStamp checksum cREVGeneral revUniqueID
1389879077895 dgHorizontalComponents i
cGlx2TimeStamp checksum cREVGeneral revUniqueID
1389879079574
dgHScrollbar Ia
$ zrevDataGridLibrary } 77 840 cGlx2TimeStamp checksum ُ B~ cREVGeneral revUniqueID
1389879079575 dgCornerPiece K@ @@@@@@ _ cGlx2TimeStamp checksum cREVGeneral revUniqueID
1389879079576 dgScrollbar I` ~ _ $ frevDataGridLibrary PS 351 cGlx2TimeStamp checksum ُ B~ cREVGeneral revUniqueID
1389879079577scripteditorvscroll 0scripteditorselection 0 tabelle Eu :on menuPick pItemName
aggiornatabella
end menuPick
F f cREVGeneral scripteditorvscroll 0revUniqueID
1389879086263scripteditorselection 29
7 Label Field E d 8
cREVTable currentview Query: cREVGeneral revUniqueID
1389887051154 Query:
9 query )` f z Z
cREVGeometry Master,scaleBottomObjectSide BottomMaster,movehDistance falseMaster,scaleBottomscaleBottom trueMaster trueMaster,scaleLeftObjectRef cardMaster,scaleBottomObjectRef cardMaster,scaleBottomAbsolute falseMaster,scaleBottom trueMaster,scaleLeftObjectSide LeftMaster,movevDistance falseMaster,scalebottomDistance -0.54893Master,expectedRect 10,102,486,222Master,scaleRightAbsolute trueMaster,scaleRight trueMaster,scalerightDistance -12Master,scaleRightObjectRef cardMaster,scaleRightObjectSide RightMaster,scaleLeftAbsolute trueMaster,scaleLeft trueMaster,cardRanking 3Master,scaletopDistance Master,scaleleftDistance 12 cREVGeneral revUniqueID
1389887094078 : ` @ g
l Z ; a @
Z
<