i'm new on berkeley db and i have a little question about your example code of Vendors and Inventory.
How could i open created databases 'vendor.db' or 'inventory.db' for read without the need of create it on every app execution?
I want to read some database records but i don't want to loose time reading from vendors.txt and doing put's on VendorDb.
thank you.
bye!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Just modify the Open method, or create a new one.
I would strongly suggest you read up on the Berkeley Db docs, as this C# wrapper assumes you already know Berkeley Db.
hello,
i'm new on berkeley db and i have a little question about your example code of Vendors and Inventory.
How could i open created databases 'vendor.db' or 'inventory.db' for read without the need of create it on every app execution?
I want to read some database records but i don't want to loose time reading from vendors.txt and doing put's on VendorDb.
thank you.
bye!
Just modify the Open method, or create a new one.
I would strongly suggest you read up on the Berkeley Db docs, as this C# wrapper assumes you already know Berkeley Db.
Anyway, here is some code for the Open method:
public void OpenReadOnly(string dbDir, string appName, Stream errStream) {
this.dbDir = dbDir;
// open vendor database
Db db = new Db(DbCreateFlags.None);
db.ErrorPrefix = appName;
db.ErrorStream = errStream;
vendorDb = (DbBTree)db.Open(null, VendorDbName, null, DbType.BTree, Db.OpenFlags.ReadOnly, 0);
// open inventory database
db = new Db(DbCreateFlags.None);
db.ErrorPrefix = appName;
db.ErrorStream = errStream;
inventoryDb = (DbBTree)db.Open(null, InventoryDbName, null, DbType.BTree, Db.OpenFlags.ReadOnly, 0);
// open & associate vendor name index
db = new Db(DbCreateFlags.None);
db.ErrorPrefix = appName;
db.ErrorStream = errStream;
db.SetFlags(DbFlags.Dup | DbFlags.DupSort);
vendorNameIdx = (DbBTree)db.Open(null, VendorIndexName, null, DbType.BTree, Db.OpenFlags.ReadOnly, 0);
// inventoryDb.Associate(vendorNameIdx, GetVendorName, DbFile.AssociateFlags.Create);
unsafe {
inventoryDb.Associate(vendorNameIdx, GetVendorNameFast, 0);
}
}