What is Berkeley DB? (Wikipedia) - Official page (Oracle site)
| Main downloads: | |
| Unit db_h.pas with the Berkeley DB access API (db.h conversion) | download |
| File with the necessary DLLs for using Berkeley DB | download |
| Delphi project with examples of Berkeley DB access | download |
| Supplementary downloads: | |
| Validator of correctness of Delphi conversion | download |
| db.h file from which db_h.pas was created | download |
| Complete Berkeley DB 5.1.25 (installer) | download |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | type PKey = ^TKey; TKey = record Id: integer; end; PData = ^TData; TData = record Name: array[0..50] of AnsiChar; end; var FDB: PDB; cursor: PDBC; dbtKey, dbtData: DBT; key: PKey; data: PData; begin // initialize API InitBerkeleyDB; // create access handle CheckBDB(db_create(FDB, nil, 0)); try // open database CheckBDB(FDB.open(FDB, nil, 'Test.db', 'Test', DB_BTREE, DB_CREATE_, 0)); // create a cursor for retrieving the records in key order CheckBDB(FDB.cursor(FDB, nil, @cursor, 0)); try FillChar(dbtKey, Sizeof(DBT), 0); FillChar(dbtData, Sizeof(DBT), 0); // iterate thru all the records and print each one while CheckAndFoundBDB(cursor.get(cursor, @dbtKey, @dbtData, DB_NEXT)) do begin key := PKey(dbtKey.data); data := PData(dbtData.data); Memo.Lines.Add('Key: '+IntToStr(key.Id)); Memo.Lines.Add('Data: '+data.Name); end; finally // free cursor CheckBDB(cursor.close(cursor)); end; finally // close database and free handle CheckBDBandNil(FDB.close(FDB, 0), FDB); end;end; |