From 3180d51c8f85bbc8a68269dc80c1b09474b2f1f5 Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Sat, 2 Sep 2023 20:01:29 +0200 Subject: [PATCH 1/4] Adds Multiprocessing example project [EXAMPLES] * NEW: misc/Multiprocessing --- app/examples/Misc/Multiprocessing/.directory | 2 + app/examples/Misc/Multiprocessing/.icon.png | Bin 0 -> 11390 bytes app/examples/Misc/Multiprocessing/.project | 15 +++++++ .../Multiprocessing/.src/CalcPrimesTask.class | 17 +++++++ .../Misc/Multiprocessing/.src/FMain.class | 26 +++++++++++ .../Misc/Multiprocessing/.src/FMain.form | 42 ++++++++++++++++++ .../Misc/Multiprocessing/.src/Primes.module | 21 +++++++++ 7 files changed, 123 insertions(+) create mode 100644 app/examples/Misc/Multiprocessing/.directory create mode 100644 app/examples/Misc/Multiprocessing/.icon.png create mode 100644 app/examples/Misc/Multiprocessing/.project create mode 100644 app/examples/Misc/Multiprocessing/.src/CalcPrimesTask.class create mode 100644 app/examples/Misc/Multiprocessing/.src/FMain.class create mode 100644 app/examples/Misc/Multiprocessing/.src/FMain.form create mode 100644 app/examples/Misc/Multiprocessing/.src/Primes.module diff --git a/app/examples/Misc/Multiprocessing/.directory b/app/examples/Misc/Multiprocessing/.directory new file mode 100644 index 000000000..06dab1c8a --- /dev/null +++ b/app/examples/Misc/Multiprocessing/.directory @@ -0,0 +1,2 @@ +[Desktop Entry] +Icon=./.icon.png diff --git a/app/examples/Misc/Multiprocessing/.icon.png b/app/examples/Misc/Multiprocessing/.icon.png new file mode 100644 index 0000000000000000000000000000000000000000..36289f1f74ecb64868140fad372b23b71d2cb087 GIT binary patch literal 11390 zcmch7cQl;Q*X}zEMju3PL-dGFNHAKWga|>R3qhiV2+@raA$p145{c*~qPI~eA~MlM z?_Kmh%zgd7``xv^`~SVxtTnUV<2`Nf^Xz9o`$Rl^piW7~LIwZ;rKX0OJ^(<#pAY~> z41SrtDzF2;pzbP~1~Bl?5B4k^01$wtnzDgc=2n)b(=$z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vF}%(5g}i1XNLu&I-4m^CRMh`~06z%L%HX z*In3?DIV%l8D=8`BHqh}@v8o5_V)fkgm9t!x{vcM2)7x)jiR7{neem%KcB9U5J9lY+qU)-_9g9HB3*{Z>%CHe+UfXwF7jEnPXa1m2aS)! z$nNK#(y?#x_XQ4ubvz@60o?vOu)25S-3ac(=a73%@2a0s+q!8NpDhE%K^SRjH!>yvtVAmo|_fU`Jn750Te zE2aK*kBCB*%|M+AywNHE(*Q5C{@<0tn{8KhL3rGM)dRu0qWJ$QC7O*Bo$RM9LgAg} zLBS}n2XH(7cj58Z7jqPz0cTzWpF literal 0 HcmV?d00001 diff --git a/app/examples/Misc/Multiprocessing/.project b/app/examples/Misc/Multiprocessing/.project new file mode 100644 index 000000000..64f88648a --- /dev/null +++ b/app/examples/Misc/Multiprocessing/.project @@ -0,0 +1,15 @@ +# Gambas Project File 3.0 +Title=Multiprocessing Example +Startup=FMain +Version=1.0.0 +Component=gb.image +Component=gb.gui +Component=gb.form +Component=gb.data +Description="Learn to use a Task to do some background calculations. \n\nThe Task class allows long running calculations to be executed in spawned\nprocess(es) to prevent UI from blocking during long running calculations.\nIn this example prime numbers up to a max number are calculated which \ntakes some time for big numbes. \n\nTherefore a single Task instance takes care of this calculation in \nthe background." +Authors="Martin Fischer" +TabSize=4 +Language=en_US +Vendor=mfischer +Packager=1 +GambasVersion=3.16 diff --git a/app/examples/Misc/Multiprocessing/.src/CalcPrimesTask.class b/app/examples/Misc/Multiprocessing/.src/CalcPrimesTask.class new file mode 100644 index 000000000..d0f7319df --- /dev/null +++ b/app/examples/Misc/Multiprocessing/.src/CalcPrimesTask.class @@ -0,0 +1,17 @@ +' Gambas class file + +''' This is a task implementation that runs in a new forked process when constructed + +Inherits Task + +Private maxPrime As Long + +Public Procedure _new(a_maxPrime As Long) + maxPrime = a_maxPrime + Application.Priority = 5 ' make this process nicer +End + +Public Function Main() As Variant + ' Note that the result of a Task has to be serializable to be passed to the main process + Return Primes.calcPrimesUpTo(maxPrime).Count +End diff --git a/app/examples/Misc/Multiprocessing/.src/FMain.class b/app/examples/Misc/Multiprocessing/.src/FMain.class new file mode 100644 index 000000000..8beffd966 --- /dev/null +++ b/app/examples/Misc/Multiprocessing/.src/FMain.class @@ -0,0 +1,26 @@ +' Gambas class file + +Private primesTask As Task + +Public Procedure btnStart_Click() + ' background process ist started with construction of Task instance + primesTask = New CalcPrimesTask(valMaxPrimes.Value) As "taskEvents" + + btnStart.Enabled = False + valResult.Value = Null + calcSpinner.Show + calcSpinner.Start +End + +Public Procedure taskEvents_Kill() + ' the background process has terminated -> fetch the result value + ' Note that task.Value might raise an error if the task itself raised an error + valResult.Value = primesTask.Value + +Finally + btnStart.Enabled = True + calcSpinner.Stop + calcSpinner.Hide +Catch + Message.Error("Something went wrong during background calculation: " & Error.Text) +End diff --git a/app/examples/Misc/Multiprocessing/.src/FMain.form b/app/examples/Misc/Multiprocessing/.src/FMain.form new file mode 100644 index 000000000..8ccd8ed2d --- /dev/null +++ b/app/examples/Misc/Multiprocessing/.src/FMain.form @@ -0,0 +1,42 @@ +# Gambas Form File 3.0 + +{ Form Form + MoveScaled(0,0,64,41) + Resizable = False + { btnStart Button + MoveScaled(46,21,17,6) + Text = ("Start Calculation \nin background") + } + { valMaxPrimes ValueBox + MoveScaled(12,21,30,4) + Text = ("200000") + } + { Label1 Label + MoveScaled(0,0,64,18) + Background = Color.LightForeground + Border = Border.Plain + Text = ("Task class allows long running calculations to be executed in spawned\nprocess(es) to prevent UI from blocking during long running calculations.\nIn this example prime numbers up to a max number are calculated which \ntakes some time for big numbes. \n\nTherefore a single Task instance takes care of this calculation in \nthe background.") + } + { Label2 Label + MoveScaled(1,21,11,3) + Text = ("max prime:") + } + { Slider1 Slider + MoveScaled(1,32,62,4) + } + { Label3 Label + MoveScaled(1,36,23,3) + Text = ("Number of found primes:") + } + { valResult ValueBox + MoveScaled(25,36,17,4) + Enabled = False + } + { Label4 Label + MoveScaled(1,29,61,3) + Text = ("Use this slider to show that the UI is responsive during calculation") + } + { calcSpinner Spinner + MoveScaled(24.2857,36,5,4) + } +} diff --git a/app/examples/Misc/Multiprocessing/.src/Primes.module b/app/examples/Misc/Multiprocessing/.src/Primes.module new file mode 100644 index 000000000..9a5e548ed --- /dev/null +++ b/app/examples/Misc/Multiprocessing/.src/Primes.module @@ -0,0 +1,21 @@ +' Gambas module file + +'' Calculates all prime numbers that are smaller or equal to the given maxNum argument. +'' Note: this is a brute-force algo. Do not use in production! +Fast Public Function calcPrimesUpTo(maxNum As Long) As List + Dim res As New List + Dim p As Long = 1 + + For n As Long = 1 To maxNum + For i As Long = 2 To (n - 1) + If n Mod i = 0 Then + p = 0 + Break + Else + p = 1 + End If + Next + If p = 1 Then res.Append(n) + Next + Return res +End Function From c8148252bc0d338bc946cb8f096aea8bdd9c7a9a Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Sat, 2 Sep 2023 20:37:05 +0200 Subject: [PATCH 2/4] Adds the DatabaseEditor example [EXAMPLES] * NEW: Database/DatabaseEditor --- .../Database/DatabaseEditor/.directory | 2 + .../Database/DatabaseEditor/.icon.png | Bin 0 -> 11390 bytes app/examples/Database/DatabaseEditor/.project | 18 +++++ .../Database/DatabaseEditor/.src/FMain.class | 19 +++++ .../Database/DatabaseEditor/.src/FMain.form | 65 ++++++++++++++++++ .../Database/DatabaseEditor/.src/Main.module | 45 ++++++++++++ .../Database/DatabaseEditor/README.md | 22 ++++++ .../Database/DatabaseEditor/test.sqlite | Bin 0 -> 49152 bytes 8 files changed, 171 insertions(+) create mode 100644 app/examples/Database/DatabaseEditor/.directory create mode 100644 app/examples/Database/DatabaseEditor/.icon.png create mode 100644 app/examples/Database/DatabaseEditor/.project create mode 100644 app/examples/Database/DatabaseEditor/.src/FMain.class create mode 100644 app/examples/Database/DatabaseEditor/.src/FMain.form create mode 100644 app/examples/Database/DatabaseEditor/.src/Main.module create mode 100644 app/examples/Database/DatabaseEditor/README.md create mode 100644 app/examples/Database/DatabaseEditor/test.sqlite diff --git a/app/examples/Database/DatabaseEditor/.directory b/app/examples/Database/DatabaseEditor/.directory new file mode 100644 index 000000000..06dab1c8a --- /dev/null +++ b/app/examples/Database/DatabaseEditor/.directory @@ -0,0 +1,2 @@ +[Desktop Entry] +Icon=./.icon.png diff --git a/app/examples/Database/DatabaseEditor/.icon.png b/app/examples/Database/DatabaseEditor/.icon.png new file mode 100644 index 0000000000000000000000000000000000000000..36289f1f74ecb64868140fad372b23b71d2cb087 GIT binary patch literal 11390 zcmch7cQl;Q*X}zEMju3PL-dGFNHAKWga|>R3qhiV2+@raA$p145{c*~qPI~eA~MlM z?_Kmh%zgd7``xv^`~SVxtTnUV<2`Nf^Xz9o`$Rl^piW7~LIwZ;rKX0OJ^(<#pAY~> z41SrtDzF2;pzbP~1~Bl?5B4k^01$wtnzDgc=2n)b(=$z<89dF)z7J`W@6D%%rwpeQ z2B!wIlZ8bkuM>tL+9aT+5(xCsRLjY;li3h}wPlRIgXH`fy5-yo)-q0V%4dB2`Ms(` z3v=_~YFAB(#9v!mG>V;(DWZv*67`EJE!!kK8g?yyq7tX`6AR==)R$eY1j_KPP*Gn1 zsw_-R3qbX(Gyu3-5En!VP80?Ol&>-UzkMiP?i(Csx_G-pq&r4i z(SE1DIEqleAm=P~aK$?Bc)#CUmhiK@KW=8(G=oUa^K*DdXowGqawf z=`3kvv8@8bD^Dff$oDE@@0K_>AHKv7R<#~)iz+4{T+jq#PE2*Rp1UtTXP%@fBIQn* zZQv5eisI(aqjGLsyv^D5`DcIm#$S=^UZODGLeTAfuYCF2*wE0V^^e_mE>8~~^|h3~ z9h@Bay^<2SXbu+~9Toc#xUW8QvCEn14^@t;qhVAc532f(6q_PQl{x*|5*zI}_h<#m zS_R)jVtue<(rEO_nsL|fdKZiHSS0eIVSPKZ%XMUfE*%+2Vehb)V^7Lf+v2g_*N5Nb zTO@S6yAB=z$CUATDE3ICJarY}JcYZ~&XYj`UG@3CTR(@ySYX8o|Fl3Rq0_ zA#*ws`GC}0t5}zVx&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3Bm;rI?ZI%6&E7=He1?+aWzlMG+U7@L-(HS^ z0WL@dL6Y{cRMo%KD|rNz7(p4>Ym#Fg6ra>BQfqJxe>WUBTfx>Uz4nP{S`O*nI!kvj zL+N+DImGs1+H{RbLGqJypyc0o&*GNY17&*naUYz z@okB%jMFaB zq*OfesK~B?ikjxXf(R4-6WSbe57BnG1iMaPeB&rW zkVN!^>tH-6;ma9V^tuU(3dFHZtKR{Qlz+r)MaokJk97PzTK1vn=A!6)$B)mL3%|I& z;ZqR1yU%}KKsJE$234S^2M+DuY|*n6AWV=P(gyQ*Kxmf;I_qm@QBeDZ`=QMGjA$n3 zYx*_!+AxjMTk4quxL_$f4-a6(^knlN^qIjb#H+XlQKN=hu_@h<0+QhK1L1~3UZ z*qi(wQ75sIa{JSg3i#}~^ej7Kf-!d%T*19>vF}%(5g}i1XNLu&I-4m^CRMh`~06z%L%HX z*In3?DIV%l8D=8`BHqh}@v8o5_V)fkgm9t!x{vcM2)7x)jiR7{neem%KcB9U5J9lY+qU)-_9g9HB3*{Z>%CHe+UfXwF7jEnPXa1m2aS)! z$nNK#(y?#x_XQ4ubvz@60o?vOu)25S-3ac(=a73%@2a0s+q!8NpDhE%K^SRjH!>yvtVAmo|_fU`Jn750Te zE2aK*kBCB*%|M+AywNHE(*Q5C{@<0tn{8KhL3rGM)dRu0qWJ$QC7O*Bo$RM9LgAg} zLBS}n2XH(7cj58Z7jqPz0cTzWpF literal 0 HcmV?d00001 diff --git a/app/examples/Database/DatabaseEditor/.project b/app/examples/Database/DatabaseEditor/.project new file mode 100644 index 000000000..538e99869 --- /dev/null +++ b/app/examples/Database/DatabaseEditor/.project @@ -0,0 +1,18 @@ +# Gambas Project File 3.0 +Title=DatabaseEditor +Startup=Main +Version=0.1.0 +Component=gb.image +Component=gb.gui +Component=gb.form +Component=gb.db +Component=gb.db.form +Component=gb.db.sqlite3 +Description="Example program that demonstrates how to use data-bound controls to edit databse records.\nI use DataSource, DataBrowser, DataControl and DataCombo here.\nNote that this example builds up the DB connection programmatically." +Authors="Martin Fischer" +TabSize=4 +Language=en_US +Vendor=MartinFischer +Packager=1 +Tags=Example,Database +GambasVersion=3.16 diff --git a/app/examples/Database/DatabaseEditor/.src/FMain.class b/app/examples/Database/DatabaseEditor/.src/FMain.class new file mode 100644 index 000000000..c8bb8962c --- /dev/null +++ b/app/examples/Database/DatabaseEditor/.src/FMain.class @@ -0,0 +1,19 @@ +' Gambas class file + +Public Sub Form_Open() + Db.Debug = True ' log all database requests made by the runtime + + ' bind the dataSource to the opened DB connection + personDataSource.Connection = Db.Current + ' Add labels to the grid's column headers manually. + ' You can do this also at design-time via properties of the DataBrowser control. + personDataBrowser.Labels = ["Vorname", "Nachname", "Geburtstag"] + personDataBrowser.Update + + With personDataBrowser.View + .Columns[0].Width = 150 ' make the columns sizees fit + .Columns[1].Width = 150 + .Columns[2].Width = 200 + .MoveTo(0, 0) ' activate the first row so that the data-bound controls show details of this row + End With +End diff --git a/app/examples/Database/DatabaseEditor/.src/FMain.form b/app/examples/Database/DatabaseEditor/.src/FMain.form new file mode 100644 index 000000000..fae18e7bb --- /dev/null +++ b/app/examples/Database/DatabaseEditor/.src/FMain.form @@ -0,0 +1,65 @@ +# Gambas Form File 3.0 + +{ Form Form + MoveScaled(0,0,98,65) + Resizable = False + { lblIntro Label + MoveScaled(-1,0,99,6) + Background = Color.LightForeground + Alignment = Align.Center + Border = Border.Plain + Text = ("Example of how to use a (runtime) database connection and data-bound controls.") + } + { personDataSource DataSource + MoveScaled(0,6,98,58) + Table = "person2" + { personDataBrowser DataBrowser + MoveScaled(1,1,96,31) + Columns = ["given_name", "sir_name", "birthdate"] + Grid = True + } + { dataId DataControl + MoveScaled(19,33,32,4) + Enabled = False + Field = "person_id" + } + { dataSex DataCombo + MoveScaled(19,38,32,4) + Field = "sex_id" + Table = "sex" + Display = "name" + } + { dataGivenName DataControl + MoveScaled(19,43,32,4) + Field = "given_name" + } + { dataSirName DataControl + MoveScaled(19,48,32,4) + Field = "sir_name" + } + { dataBirthdate DataControl + MoveScaled(19,53,32,4) + Field = "birthdate" + } + { Label1 Label + MoveScaled(1,43,16,3) + Text = ("Vorname") + } + { Label2 Label + MoveScaled(1,48,16,3) + Text = ("Nachname") + } + { Label3 Label + MoveScaled(1,53,16,3) + Text = ("Geburtstag") + } + { Label4 Label + MoveScaled(1,33,17,3) + Text = ("Id (Auto)") + } + { Label5 Label + MoveScaled(1,38,17,3) + Text = ("Geschlecht") + } + } +} diff --git a/app/examples/Database/DatabaseEditor/.src/Main.module b/app/examples/Database/DatabaseEditor/.src/Main.module new file mode 100644 index 000000000..9af0c7795 --- /dev/null +++ b/app/examples/Database/DatabaseEditor/.src/Main.module @@ -0,0 +1,45 @@ +' Gambas module file + +' Use Main To start up this program because there is a bug in gambas that +' causes data-bound controls (e.g.DataCombo) to misbehave if connection is +' set to a DataSource after the controls have been already initialized. +' This means that creating the connection in Form_Open() is too late. +Public Sub Main() + Dim conn As Connection + Try conn = openConnection() + printPersons(conn) + ' store the now open connection in DB.Current for the forms to get access to it + Db.Current = conn + FMain.Show + +Catch + Message.Error("Could not open connection to DB: " & DConv(Error.Text)) + Quit +End + +Public Procedure Application_Error() + Debug "Unhandled Error: ", Error.Text, Error.Code, Error.Backtrace +End + +Private Function openConnection() As Connection + Dim result As New Connection + With result + .Type = "sqlite3" + .Host = Application.Path ' Database if part of the project dir + .Name = "test.sqlite" + End With + result.Open + Return result +End + +'' prints out all persons in the DB so far for debugging purposes +Private Procedure printPersons(conn As Connection) + Dim rs As Result + rs = conn.Exec("SELECT * FROM person2") + While rs.Available + Debug Subst( + "Person: person_id=&{1}, sex_id=&{2}, name=&{3}, sirname=&{4}, birthdate=&{5}", + rs["person_id"], rs["sex_id"], rs["given_name"], rs["sir_name"], rs["birthdate"]) + rs.MoveNext + Wend +End diff --git a/app/examples/Database/DatabaseEditor/README.md b/app/examples/Database/DatabaseEditor/README.md new file mode 100644 index 000000000..ff5165a21 --- /dev/null +++ b/app/examples/Database/DatabaseEditor/README.md @@ -0,0 +1,22 @@ +## README + +This example uses a sqlite3 DB. +One speciality with respect to gambas is that you have to be careful how to +define the schema. gambas will read this schema definition later and extract +some information from it. + +Expecially the autoincrement feature often used for primary key columns +is affected by this. You can specify a PK with autoincrement in a lot of ways +that are all valid table definitions. The problem is that gambas only understands +some of then. + +Here is the one that works: specify AUTOINCREMENT together with the column definition like so: + ... + person_id INTEGER PRIMARY KEY AUTOINCREMENT, + ... + +When AUTOINCREMENT is not part of the column definition, gambas will not recognize +the fact that there is no need to provide a person_id value for insertions. + +As a consequence you would have to bind the person_id to a data-bound control +to manually let the user provide this id for each new record (which does not make much sense). \ No newline at end of file diff --git a/app/examples/Database/DatabaseEditor/test.sqlite b/app/examples/Database/DatabaseEditor/test.sqlite new file mode 100644 index 0000000000000000000000000000000000000000..f9a617a7fca292ba144408b31e78c80a89ff7484 GIT binary patch literal 49152 zcmeI*Pfyce9KiACX<=iqQ4>N4F41PjI0VfA4=NWY6dZ0v%BJCj1*$ZGO}1gY8TE~L ztZe3OvQ3;(OGaj`;nI`WW81Up|fgdOU0#}tJW7Bw>Y8Z z*Me6kCc8^T+b!kudhB`lGAOT={hc5cdz|%VA7s7s?aY{cd`>N_{$<8`Sgmhu`gQdo zb1G`}!ShR=lUs0gKW47naJD%gtIxDvBO#K?_AKSYa9T^&uZqWO@V$6_j$gm4$;il^At}Q0rpkDCTm5ES z^Y`kN#`T)cb5b2*kIcx(__$nc+BB!tg5ABKyb-ikwJ&>4nEf`G)-n@n>X;Dn={e@z z^|wx_3=Qi*Sf8u|>qFP4OM(a>fB*srAbqbP#YbG9qH5Nm1~t^{_l2*7UrNN}6C1KmY**5I_I{ z1Q0*~0R#|0;GYB%))yhIBViq>0|fyD5I_I{1Q0*~0R#|0009I#Qs7E6>Vc@4l&z<8 z^fUbWxqb=)2q1s}0tg_000IagfB*srAbKt(1d)!<3`Oe6Zth2T^Iph70OMzem8dJ`3x+^;I<#1Q0*~0R#|0009ILKmY** z5a Date: Sat, 2 Sep 2023 20:44:26 +0200 Subject: [PATCH 3/4] Adds the DatabaseEditorDesignTimeConnection example [EXAMPLES] * NEW: Database/DatabaseEditorDesignTimeConnection --- .../.connection/personConnection.connection | 12 ++++ .../.connection/personConnection.template | 65 ++++++++++++++++++ .../.directory | 2 + .../.icon.png | Bin 0 -> 11390 bytes .../.project | 17 +++++ .../.src/FMain.class | 14 ++++ .../.src/FMain.form | 58 ++++++++++++++++ .../README.md | 22 ++++++ .../person.sqlite | Bin 0 -> 53248 bytes 9 files changed, 190 insertions(+) create mode 100644 app/examples/Database/DatabaseEditorDesignTimeConnection/.connection/personConnection.connection create mode 100644 app/examples/Database/DatabaseEditorDesignTimeConnection/.connection/personConnection.template create mode 100644 app/examples/Database/DatabaseEditorDesignTimeConnection/.directory create mode 100644 app/examples/Database/DatabaseEditorDesignTimeConnection/.icon.png create mode 100644 app/examples/Database/DatabaseEditorDesignTimeConnection/.project create mode 100644 app/examples/Database/DatabaseEditorDesignTimeConnection/.src/FMain.class create mode 100644 app/examples/Database/DatabaseEditorDesignTimeConnection/.src/FMain.form create mode 100644 app/examples/Database/DatabaseEditorDesignTimeConnection/README.md create mode 100644 app/examples/Database/DatabaseEditorDesignTimeConnection/person.sqlite diff --git a/app/examples/Database/DatabaseEditorDesignTimeConnection/.connection/personConnection.connection b/app/examples/Database/DatabaseEditorDesignTimeConnection/.connection/personConnection.connection new file mode 100644 index 000000000..4057a533b --- /dev/null +++ b/app/examples/Database/DatabaseEditorDesignTimeConnection/.connection/personConnection.connection @@ -0,0 +1,12 @@ +# Gambas Connection File 3.0 +[Connection] +Type="sqlite" +Path="." +NoPassword=False +RememberPassword=False +IgnoreCharset=False +DisplayMetadata=True +RememberTemplate=True +Database="person.sqlite" +Requests=[""] + diff --git a/app/examples/Database/DatabaseEditorDesignTimeConnection/.connection/personConnection.template b/app/examples/Database/DatabaseEditorDesignTimeConnection/.connection/personConnection.template new file mode 100644 index 000000000..f0d3fec7d --- /dev/null +++ b/app/examples/Database/DatabaseEditorDesignTimeConnection/.connection/personConnection.template @@ -0,0 +1,65 @@ +# Gambas Database Template File 3.0 +{ Table + Name="__gb_metadata_v2" + PrimaryKey=["sTableName","iType","sKey"] + { Field + Name="sTableName" + Type=db.String + } + { Field + Name="iType" + Type=db.Integer + } + { Field + Name="sKey" + Type=db.String + } + { Field + Name="sValue" + Type=db.String + } +} +{ Table + Name="person2" + PrimaryKey=["person_id"] + { Field + Name="person_id" + Type=db.Serial + } + { Field + Name="sex_id" + Type=db.Integer + } + { Field + Name="given_name" + Type=db.String + Length=80 + } + { Field + Name="sir_name" + Type=db.String + Length=80 + } + { Field + Name="birthdate" + Type=db.Date + } +} +{ Table + Name="sex" + PrimaryKey=["sex_id"] + { Field + Name="sex_id" + Type=db.Integer + } + { Field + Name="name" + Type=db.String + Length=80 + } + { Index + Name="idx_sex_sex_id" + Unique=True + Fields=["sex_id"] + } +} diff --git a/app/examples/Database/DatabaseEditorDesignTimeConnection/.directory b/app/examples/Database/DatabaseEditorDesignTimeConnection/.directory new file mode 100644 index 000000000..06dab1c8a --- /dev/null +++ b/app/examples/Database/DatabaseEditorDesignTimeConnection/.directory @@ -0,0 +1,2 @@ +[Desktop Entry] +Icon=./.icon.png diff --git a/app/examples/Database/DatabaseEditorDesignTimeConnection/.icon.png b/app/examples/Database/DatabaseEditorDesignTimeConnection/.icon.png new file mode 100644 index 0000000000000000000000000000000000000000..36289f1f74ecb64868140fad372b23b71d2cb087 GIT binary patch literal 11390 zcmch7cQl;Q*X}zEMju3PL-dGFNHAKWga|>R3qhiV2+@raA$p145{c*~qPI~eA~MlM z?_Kmh%zgd7``xv^`~SVxtTnUV<2`Nf^Xz9o`$Rl^piW7~LIwZ;rKX0OJ^(<#pAY~> z41SrtDzF2;pzbP~1~Bl?5B4k^01$wtnzDgc=2n)b(=$z<89dF)z7J`W@6D%%rwpeQ z2B!wIlZ8bkuM>tL+9aT+5(xCsRLjY;li3h}wPlRIgXH`fy5-yo)-q0V%4dB2`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neem%KcB9U5J9lY+qU)-_9g9HB3*{Z>%CHe+UfXwF7jEnPXa1m2aS)! z$nNK#(y?#x_XQ4ubvz@60o?vOu)25S-3ac(=a73%@2a0s+q!8NpDhE%K^SRjH!>yvtVAmo|_fU`Jn750Te zE2aK*kBCB*%|M+AywNHE(*Q5C{@<0tn{8KhL3rGM)dRu0qWJ$QC7O*Bo$RM9LgAg} zLBS}n2XH(7cj58Z7jqPz0cTzWpF literal 0 HcmV?d00001 diff --git a/app/examples/Database/DatabaseEditorDesignTimeConnection/.project b/app/examples/Database/DatabaseEditorDesignTimeConnection/.project new file mode 100644 index 000000000..8834f0684 --- /dev/null +++ b/app/examples/Database/DatabaseEditorDesignTimeConnection/.project @@ -0,0 +1,17 @@ +# Gambas Project File 3.0 +Title=DatabaseEditor +Startup=FMain +Version=1.0.0 +Component=gb.image +Component=gb.gui +Component=gb.form +Component=gb.db +Component=gb.db.form +Component=gb.db.sqlite3 +Description="Example program that demonstrates how to use data-bound controls to edit databse records.\nI use DataSource, DataBrowser, DataControl and DataCombo here.\n\nNote that this example uses a connection to the DB that is specified at design-time via the gambas IDE. As a consequence the IDE provides support when binding controls to tables and fields by offering the available tables or field names." +TabSize=4 +Language=en_US +Vendor=MartinFischer +Packager=1 +Tags=Database,Example +GambasVersion=3.18 diff --git a/app/examples/Database/DatabaseEditorDesignTimeConnection/.src/FMain.class b/app/examples/Database/DatabaseEditorDesignTimeConnection/.src/FMain.class new file mode 100644 index 000000000..4ed31dbae --- /dev/null +++ b/app/examples/Database/DatabaseEditorDesignTimeConnection/.src/FMain.class @@ -0,0 +1,14 @@ +' Gambas class file + +Public Sub Form_Open() + Db.Debug = True ' log all database requests made by the runtime + + ' adjust column width + With personDataBrowser.View + .Columns[0].Width = 150 ' adjust column widths + .Columns[1].Width = 150 + .Columns[2].Width = 200 + .MoveTo(0, 0) ' activate first row so that data-bound controls get filled with data for this row + End With +End + diff --git a/app/examples/Database/DatabaseEditorDesignTimeConnection/.src/FMain.form b/app/examples/Database/DatabaseEditorDesignTimeConnection/.src/FMain.form new file mode 100644 index 000000000..1d6716dbe --- /dev/null +++ b/app/examples/Database/DatabaseEditorDesignTimeConnection/.src/FMain.form @@ -0,0 +1,58 @@ +# Gambas Form File 3.0 + +{ Form Form + MoveScaled(0,0,98,59) + Resizable = False + { lblIntro Label + MoveScaled(-1,0,99,6) + Background = Color.LightForeground + Alignment = Align.Center + Border = Border.Plain + Text = ("Example of how to use a (design-time) database connection and data-bound controls.") + } + { personDataSource DataSource + MoveScaled(0,6,98,53) + Connection = Connections["personConnection"] + Table = "person2" + { personDataBrowser DataBrowser + MoveScaled(1,1,96,31) + Columns = ["given_name", "sir_name", "birthdate"] + Labels = ["Vorname", "Nachname", "Geburtstag"] + Grid = True + } + { dataSex DataCombo + MoveScaled(19,33,32,4) + Field = "sex_id" + Table = "sex" + Display = "name" + } + { dataGivenName DataControl + MoveScaled(19,38,32,4) + Field = "given_name" + } + { dataSirName DataControl + MoveScaled(19,43,32,4) + Field = "sir_name" + } + { dataBirthdate DataControl + MoveScaled(19,48,32,4) + Field = "birthdate" + } + { Label1 Label + MoveScaled(1,38,16,3) + Text = ("Vorname") + } + { Label2 Label + MoveScaled(1,43,16,3) + Text = ("Nachname") + } + { Label3 Label + MoveScaled(1,48,16,3) + Text = ("Geburtstag") + } + { Label5 Label + MoveScaled(1,33,17,3) + Text = ("Geschlecht") + } + } +} diff --git a/app/examples/Database/DatabaseEditorDesignTimeConnection/README.md b/app/examples/Database/DatabaseEditorDesignTimeConnection/README.md new file mode 100644 index 000000000..ff5165a21 --- /dev/null +++ b/app/examples/Database/DatabaseEditorDesignTimeConnection/README.md @@ -0,0 +1,22 @@ +## README + +This example uses a sqlite3 DB. +One speciality with respect to gambas is that you have to be careful how to +define the schema. gambas will read this schema definition later and extract +some information from it. + +Expecially the autoincrement feature often used for primary key columns +is affected by this. You can specify a PK with autoincrement in a lot of ways +that are all valid table definitions. The problem is that gambas only understands +some of then. + +Here is the one that works: specify AUTOINCREMENT together with the column definition like so: + ... + person_id INTEGER PRIMARY KEY AUTOINCREMENT, + ... + +When AUTOINCREMENT is not part of the column definition, gambas will not recognize +the fact that there is no need to provide a person_id value for insertions. + +As a consequence you would have to bind the person_id to a data-bound control +to manually let the user provide this id for each new record (which does not make much sense). \ No newline at end of file diff --git a/app/examples/Database/DatabaseEditorDesignTimeConnection/person.sqlite b/app/examples/Database/DatabaseEditorDesignTimeConnection/person.sqlite new file mode 100644 index 0000000000000000000000000000000000000000..f41eeba81f96bdb4996c319fdf9114bb01566c4f GIT binary patch literal 53248 zcmeI)PjA~~9Ki9%aho*BG9y(}ROP^f0V!V7sqK)U719Wu3)xzCOOw$akZ~5XSxV9^ zai@-3#~av7;KG3yz>(=DSo-*JPwnJhUK`!l;NZPIYTbmhDZuY&#qFu8b;~`9W1HI_*yIz;C%N zuj!k~TgCFm=f!gVqh(7DPVY7yv`?u~3)pQ9vWq5Lq^84VQ4#|QvyWN%l>TY4k_C!cpnQz3;uRICPQUk};i;3*glJ@A!E}-k) zsku!*^wj8i?t|6Q{n#+==;5AoC7Rk!G>2rx-c$2#F!z*oPpE*RiqO(Bs*~MQy+LUg@E9{QHM~>$cxF8tl#t z4fM#teDsbfsH&C_+E-&=io(|-5MAJ_i+&aa5I_I{1Q0*~0R#|0009ILm|}tG`afno z5yr2^6XVAz?kHVD009ILKmY**5I_I{1Q0-A0tHgNm@mfSLd(5k*hy&74yyu2S@qfP_l3D#cV{K>z^+5I_I{1Q0*~0R#|0 J0D%b?_#3_EMDhRt literal 0 HcmV?d00001 From 8c6e68fde165b9157359dd49b0f60208db78c3a0 Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Sun, 3 Sep 2023 18:46:42 +0200 Subject: [PATCH 4/4] Do no longer use sqlite db file from inside project. Instead deploy template db file from project to tmp folder at startup and use this deployed file as db then. --- .../Database/DatabaseEditor/.src/FMain.class | 1 + .../Database/DatabaseEditor/.src/FMain.form | 2 +- .../Database/DatabaseEditor/.src/Main.module | 37 +++++++++++++++--- .../Database/DatabaseEditor/README.md | 23 ++++++++++- .../Database/DatabaseEditor/db.sqlite | Bin 0 -> 49152 bytes .../.connection/personConnection.connection | 4 +- .../.project | 2 +- .../.src/FMain.class | 1 + .../.src/Main.module | 32 +++++++++++++++ .../README.md | 24 +++++++++++- .../db.sqlite | Bin 0 -> 53248 bytes 11 files changed, 112 insertions(+), 14 deletions(-) create mode 100644 app/examples/Database/DatabaseEditor/db.sqlite create mode 100644 app/examples/Database/DatabaseEditorDesignTimeConnection/.src/Main.module create mode 100644 app/examples/Database/DatabaseEditorDesignTimeConnection/db.sqlite diff --git a/app/examples/Database/DatabaseEditor/.src/FMain.class b/app/examples/Database/DatabaseEditor/.src/FMain.class index c8bb8962c..a94320f79 100644 --- a/app/examples/Database/DatabaseEditor/.src/FMain.class +++ b/app/examples/Database/DatabaseEditor/.src/FMain.class @@ -2,6 +2,7 @@ Public Sub Form_Open() Db.Debug = True ' log all database requests made by the runtime + Debug "Using DB connection: ", Db.Current.Url ' bind the dataSource to the opened DB connection personDataSource.Connection = Db.Current diff --git a/app/examples/Database/DatabaseEditor/.src/FMain.form b/app/examples/Database/DatabaseEditor/.src/FMain.form index fae18e7bb..a64092a2c 100644 --- a/app/examples/Database/DatabaseEditor/.src/FMain.form +++ b/app/examples/Database/DatabaseEditor/.src/FMain.form @@ -4,7 +4,7 @@ MoveScaled(0,0,98,65) Resizable = False { lblIntro Label - MoveScaled(-1,0,99,6) + MoveScaled(0,0,98,6) Background = Color.LightForeground Alignment = Align.Center Border = Border.Plain diff --git a/app/examples/Database/DatabaseEditor/.src/Main.module b/app/examples/Database/DatabaseEditor/.src/Main.module index 9af0c7795..af96ea7a8 100644 --- a/app/examples/Database/DatabaseEditor/.src/Main.module +++ b/app/examples/Database/DatabaseEditor/.src/Main.module @@ -1,13 +1,17 @@ ' Gambas module file +Private Const TemplateDbFileName As String = "db.sqlite" + ' Use Main To start up this program because there is a bug in gambas that ' causes data-bound controls (e.g.DataCombo) to misbehave if connection is ' set to a DataSource after the controls have been already initialized. ' This means that creating the connection in Form_Open() is too late. Public Sub Main() Dim conn As Connection + + DeployDbFile() Try conn = openConnection() - printPersons(conn) + PrintPersons(conn) ' store the now open connection in DB.Current for the forms to get access to it Db.Current = conn FMain.Show @@ -17,23 +21,44 @@ Catch Quit End -Public Procedure Application_Error() - Debug "Unhandled Error: ", Error.Text, Error.Code, Error.Backtrace +' This project contains the (initial) sqlite database file (db.sqlite) that contains the schema +' and some example records. +' To be able to write to this file, it has to be deloyed to a location where the current user +' has write permissions. +' For 'ordinary' applications this would be somewhere in Desktop.DataDir or in a user defined location. +' For this tiny example I deploy to a temp dir where the db file is cleaned up automatically after +' the process of this application terminates. +Private Procedure DeployDbFile() + Dim deployFilePath As String = GetDbDeployPath() &/ GetDbDeployFileName() + If Not Exist(deployFilePath) Then + Copy Application.Path &/ TemplateDbFileName To deployFilePath + Debug "Deployed sqlite database file to: ", deployFilePath + Endif End Private Function openConnection() As Connection Dim result As New Connection With result .Type = "sqlite3" - .Host = Application.Path ' Database if part of the project dir - .Name = "test.sqlite" + .Host = GetDbDeployPath() + .Name = GetDbDeployFileName() End With result.Open Return result End +'' Returns the path of the deploy directory. The directory of this path is guaranted to already exist. +Private Function GetDbDeployPath() As String + Return File.Dir(Temp$()) +End + +'' Returns the filename of the deployed database file +Private Function GetDbDeployFileName() As String + Return Application.Name & ".sqlite" +End + '' prints out all persons in the DB so far for debugging purposes -Private Procedure printPersons(conn As Connection) +Private Procedure PrintPersons(conn As Connection) Dim rs As Result rs = conn.Exec("SELECT * FROM person2") While rs.Available diff --git a/app/examples/Database/DatabaseEditor/README.md b/app/examples/Database/DatabaseEditor/README.md index ff5165a21..e125b6775 100644 --- a/app/examples/Database/DatabaseEditor/README.md +++ b/app/examples/Database/DatabaseEditor/README.md @@ -1,6 +1,9 @@ ## README This example uses a sqlite3 DB. + +### DB schema + One speciality with respect to gambas is that you have to be careful how to define the schema. gambas will read this schema definition later and extract some information from it. @@ -8,7 +11,7 @@ some information from it. Expecially the autoincrement feature often used for primary key columns is affected by this. You can specify a PK with autoincrement in a lot of ways that are all valid table definitions. The problem is that gambas only understands -some of then. +some of them. Here is the one that works: specify AUTOINCREMENT together with the column definition like so: ... @@ -19,4 +22,20 @@ When AUTOINCREMENT is not part of the column definition, gambas will not recogni the fact that there is no need to provide a person_id value for insertions. As a consequence you would have to bind the person_id to a data-bound control -to manually let the user provide this id for each new record (which does not make much sense). \ No newline at end of file +to manually let the user provide this id for each new record (which does not make much sense). + +### Database file + +Using the template db-file embedded within the project directory (db.sqlite) +is possible but will only work as long as the application is not deployed. Usually applications +are deployed into a location that is read-only. This means that the embedded template db-file +will also be read-only. + +Therefor this application deploys (copies) the template db-file the directory where the +temporary files of the current process are stored (usually in /tmp/gambas./) +as file named [Application.Name].sqlite. +The application connects to this deployed db-file then. + +Since this temp dir is automatically removed when the application process terminates, +all changes you made during the processes lifetime will be lost. Each start of the application +will redeploy the template db-file again at startup. \ No newline at end of file diff --git a/app/examples/Database/DatabaseEditor/db.sqlite b/app/examples/Database/DatabaseEditor/db.sqlite new file mode 100644 index 0000000000000000000000000000000000000000..f9a617a7fca292ba144408b31e78c80a89ff7484 GIT binary patch literal 49152 zcmeI*Pfyce9KiACX<=iqQ4>N4F41PjI0VfA4=NWY6dZ0v%BJCj1*$ZGO}1gY8TE~L ztZe3OvQ3;(OGaj`;nI`WW81Up|fgdOU0#}tJW7Bw>Y8Z z*Me6kCc8^T+b!kudhB`lGAOT={hc5cdz|%VA7s7s?aY{cd`>N_{$<8`Sgmhu`gQdo zb1G`}!ShR=lUs0gKW47naJD%gtIxDvBO#K?_AKSYa9T^&uZqWO@V$6_j$gm4$;il^At}Q0rpkDCTm5ES z^Y`kN#`T)cb5b2*kIcx(__$nc+BB!tg5ABKyb-ikwJ&>4nEf`G)-n@n>X;Dn={e@z z^|wx_3=Qi*Sf8u|>qFP4OM(a>fB*srAbqbP#YbG9qH5Nm1~t^{_l2*7UrNN}6C1Km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