1. EDS Issue

Hello,

So I was trying to make a simple database using EDS, but I got the error the database was not created.

include std/eds.e 
 
 
if db_create("GameData",DB_LOCK_NO) != DB_OK then 
    puts(1,"Failed to create database!\n") --this shows up in the console window 
    abort(1) 
end if 
 
new topic     » topic index » view message » categorize

2. Re: EDS Issue

Icy_Viking said...

Hello,

So I was trying to make a simple database using EDS, but I got the error the database was not created.

include std/eds.e 
 
 
if db_create("GameData",DB_LOCK_NO) != DB_OK then 
    puts(1,"Failed to create database!\n") --this shows up in the console window 
    abort(1) 
end if 
 

Does the already database file exist?

docs said...

If the database already exists, it will not be overwritten. db_create will return DB_EXISTS_ALREADY.

The value returned from db_create can be any of DB_OK, DB_EXISTS_ALREADY, DB_OPEN_FAIL, or DB_LOCK_FAIL.

I typically use this all-in-one approach. I also recommend using DB_LOCK_EXCLUSIVE by default to ensure your application has full access to the file.

public function db_load( sequence path, integer lock_method=DB_LOCK_EXCLUSIVE ) 
 
    if db_select( path ) = DB_OK then 
        return DB_OK 
    end if 
 
    if db_open( path, lock_method ) = DB_OK then 
        return DB_OK 
    end if 
 
    return db_create( path, lock_method ) 
end function 

-Greg

new topic     » goto parent     » topic index » view message » categorize

3. Re: EDS Issue

ghaberek said...
Icy_Viking said...

Hello,

So I was trying to make a simple database using EDS, but I got the error the database was not created.

include std/eds.e 
 
 
if db_create("GameData",DB_LOCK_NO) != DB_OK then 
    puts(1,"Failed to create database!\n") --this shows up in the console window 
    abort(1) 
end if 
 

Does the already database file exist?

docs said...

If the database already exists, it will not be overwritten. db_create will return DB_EXISTS_ALREADY.

The value returned from db_create can be any of DB_OK, DB_EXISTS_ALREADY, DB_OPEN_FAIL, or DB_LOCK_FAIL.

I typically use this all-in-one approach. I also recommend using DB_LOCK_EXCLUSIVE by default to ensure your application has full access to the file.

public function db_load( sequence path, integer lock_method=DB_LOCK_EXCLUSIVE ) 
 
    if db_select( path ) = DB_OK then 
        return DB_OK 
    end if 
 
    if db_open( path, lock_method ) = DB_OK then 
        return DB_OK 
    end if 
 
    return db_create( path, lock_method ) 
end function 

-Greg

Thanks Greg, it must have already existed.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu