Seite 1 von 1

[Module] JSON Datenbank(All OS)

Verfasst: 20.06.2022 10:57
von Thorsten1867
JSON Datenbank - Module (All OS / DPI)

Für ein Projekt benötige ich eine Datenbank, die ich direkt aus dem Speicher in ein Archiv packen bzw. verschlüsseln kann, ohne den Umweg über die Festplatte nehmen zu müssen. JSON scheint mir dafür der geeignete Weg zu sein.

- einfacheres Handling im Vergleich zu SQL
- Syntax für Abfragen soweit nötig an SQL angelehnt
- Abfragen können direkt in eine Linked List kopiert werden (#CopyToList)
- direktes Soeichern und Laden in bzw. aus ein(em) Archiv möglich
- AES-Verschlüsselung unterstützt
- Unterstützte Datentypen: String, Integer, Quad, Float, Double, Boolean und Blob
- Laden bzw. speichern von Blobs (z.B. Bilder) direkt aus bzw. in eine(r) Datei

Code: Alles auswählen

; jDB::Create()          - Create a new database
; jDB::Open()            - Open a database file
; jDB::Save()            - Save database as file
; jDB::AddPack()         - Save database in an archive
; jDB::UncompressPack()  - Load database from an archive
; jDB::Close()           - Close database
;
; jDB::Create()          - Create a new database
; jDB::AddTable()        - Add a database table
; jDB::AddColumn()       - Add a table column
; jDB::AddDataset()      - Add new database row with column data
; 
; jDB::Drop()            - Delete database table
; jDB::Table()           - Select a table
;
; jDB::AffectedRows()    - Number of database rows affected or selected
; jDB::ColumnType()      - Returns the type of the column (#String/#Integer/#Quad/#Float/#Double/#Blob)
; jDB::CheckNull()       - Returns #True if column = literal zero
;
; jDB::SelectRow()       - Select a row with its ID
; jDB::Query()           - Select several rows by means of an expression
; jDB::FinishQuery()     - Resets the selection and releases the resources
; jDB::Update()          - Update selected row(s) by means of an expression
; jDB::FinishUpdate()    - Resets the selection and releases the resources
; jDB::Combine()         - Combine two tables
; jDB::FinishCombine()   - Resets the selection and and removes the temporary table
; jDB::Join()            - Combine two tables and create a new table
;
; jDB::Delete()          - Delete selected row(s) by means of an expressio
; jDB::Sort()            - Change the order of the selected rows
;
; jDB::FirstRow          - Go to the first selected row
; jDB::PreviousRow()     - Go to the previous selected row
; jDB::NextRow()         - Go to the next selected row
; jDB::LastRow()         - Go to the last selected row
; jDB::ResetRows()       - Go before the first row to process all rows with NextRow()
;
; jDB::GetBoolean()      - Get the content of the column from the current row (Boolean)
; jDB::GetInteger()      - Get the content of the column from the current row (Integer)
; jDB::GetQuad()         - Get the content of the column from the current row (Quad)
; jDB::GetFloat()        - Get the content of the column from the current row (Float)
; jDB::GetDouble()       - Get the content of the column from the current row (Double)
; jDB::GetString()       - Get the content of the column from the current row (String)
;
; jDB::UpdateDataset()   - Change the value of all column from the current row
;
; jDB::SetBoolean()      - Change the value of the column from the current row (Boolean)
; jDB::SetInteger()      - Change the value of the column from the current row (Integer)
; jDB::SetQuad()         - Change the value of the column from the current row (Quad)
; jDB::SetFloat()        - Change the value of the column from the current row (Float)
; jDB::SetDouble()       - Change the value of the column from the current row (Double)
; jDB::SetString()       - Change the value of the column from the current row (String)
;
; jDB::GetBlob()         - Loads the blob into the memory
; jDB::BlobSize()        - Returns the size of the blob for allocating the memory 
; jDB::SaveBlob()        - Saves the blob as a file
;
; jDB::SetBlob()         - Saves the memory as a blob in the column
; jDB::LoadBlob()        - Saves the file as a blob in the column

; jDB::FileToBlob()      - Returns file as blob string for the use with DataSet()
; jDB::MemoryToBlob()    - Returns memory as blob string for the use with DataSet()

Download: JsonDatabaseModule.pbi

Re: [Module] JSON Datenbank(All OS)

Verfasst: 20.06.2022 11:02
von jacdelad
Sehr cool, genau was ich brauche. Vielen Dank!
Ich kann es erst später testen: Ist die Komprimierung automatisch? So in etwa wie bei "Save" einen Parameter angeben, damit die Datenbank gepackt wird? Oder muss ich den Umweg über UncompressPack und AddPack gehen?

Re: [Module] JSON Datenbank(All OS)

Verfasst: 20.06.2022 11:24
von Thorsten1867
Du kannst diese in jedes beliebige Archiv packen, wenn du dessen ID hast.

Code: Alles auswählen

If jDB::Create(#DB, "Test") 
        
  jDB::AddTable(#DB, "Table")
        
  jDB::AddColumn(#DB, "Name",   jDB::#String)
  jDB::AddColumn(#DB, "Gender", jDB::#String)
  jDB::AddColumn(#DB, "Age",    jDB::#Integer)
        
  jDB::AddDataset(#DB, "Peter|m|18", "Row1")
  jDB::AddDataset(#DB, "Sarah|f|24", "Row2")
  jDB::AddDataset(#DB, "James|m|67", "Row3")
  jDB::AddDataset(#DB, "Megan|f|14", "Row4")
        
  If CreatePack(#Pack, "Test.zip") 
          
    jDB::AddPack(#DB, #Pack, "Test.dbj")  ; <===
        
    ClosePack(#Pack) 
  EndIf
        
  jDB::Close(#DB)
EndIf

Re: [Module] JSON Datenbank(All OS)

Verfasst: 20.06.2022 12:10
von Kiffi
:allright:

Re: [Module] JSON Datenbank(All OS)

Verfasst: 20.06.2022 12:28
von Thorsten1867
Update: #Compressed für jDB::Save() & jDB::Open() hinzugefügt

Re: [Module] JSON Datenbank(All OS)

Verfasst: 20.06.2022 13:16
von jacdelad
Ah danke. Ich hätte mir das sonst selbst gebastelt.