|
Eiredrake Beginner
Joined: 14 Jun 2005 Posts: 15
|
Posted: Fri Jun 19, 2009 12:51 am
Database madness |
I'm currently using three databases to hold different types of data. It was all working pretty good at first but after a while things started going wonky. I think what is happening is that the database functionality is not actually being closed when I tell it to be or when CMUD closes.
I suspect this because after a DB freakout, if I restart CMUD i get a SQLLITE.dll error that doesn't go away until I reboot.
my question is basically this, WHEN should the #DB commands be used? Currently I do things in the following order in each alias based on my previous experience as a C# developer.
#DBLOAD "my db"
#DBONLINE
#FIND
...Other DB related stuff such as pulling values and stuff.
#DBSAVE "my db".....if mods have been made
#DBRESET
#DBOFFLINE
#DBCLOSE "my db"
Am I only supposed to open each DB once at startup and then close them at shutdown? or is this the proper way? The docs tell what the functions do but do not say when to use them.
I also notice that the first time I run one of these aliases that pulls data, it fails to find the entry I tell it to find. But if I open the DB panel and physically open the database it works just fine.
Anyone know what's going on here? |
|
|
|
Tech GURU
Joined: 18 Oct 2000 Posts: 2733 Location: Atlanta, USA
|
Posted: Fri Jun 19, 2009 2:01 pm |
Without knowing exactly what your scripts are doing it will be hard to advise. Bear in mind that you can only have on database loaded at a time. Meaning you load eq.db, the spells.db and need to access the eq.db again you will need to do another #DBLOAD on the eq.db before you can access it.
The sqllite.dll error you saw is actually Windows error. Essentially it caches the wrong sqlite (or loses track of the right one, I forget which) in the DLL cache. The cache is flushed and repopulated at reboot. At least that's the rough idea of it. |
|
_________________ Asati di tempari! |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Fri Jun 19, 2009 6:41 pm |
Also, the sqlite error is not related to your database module errors. The database module in CMUD (and zMUD) isn't actually a real "database" and doesn't use sqlite or any other database driver. It's just a flat file that is handled within memory like a database. As Tech mentioned, the sqlite error is Windows related, and is more common on Vista. Sometimes just restarting CMUD will fix it, but often you have to reboot Windows are you mentioned. It only seems to happen with the older SQLITE2.8 DLL file and not with the newer SQLITE3 DLL, but CMUD still uses both versions for now for compatibility with older package files. The 3.x BETA Version of CMUD will be getting rid of the SQLITE 2.8 stuff eventually and that will fix this issue.
As far as the database module, it is just a direct port from zMUD and still has bugs. These bugs probably won't get fixed until the database module is completely rewritten to actually use an SQL database instead of a flat file.
But looking at your script, you have DBONLINE and DBOFFLINE confused. You use DBOFFLINE to put the database in "offline" mode to do faster manipulation. Offline basically prevents the user interface window from being updated, so it speeds up your scripts. So your script should be something more like this:
#DBLOAD "my db"
#DBOFFLINE
#FIND
...Other DB related stuff such as pulling values and stuff.
#DBONLINE
#DBSAVE "my db".....if mods have been made
#DBCLOSE "my db"
where the DBOFFLINE and DBONLINE commands are really optional and should only be used if you are doing really extensive database operations. You also do not need DBRESET. DBRESET just resets the current record pointer to the beginning of the database.
But in general, the database module was originally written to be interactive with the database window. The scripting was added later and has some issues. That is why I generally recommend not using DBOFFLINE and DBONLINE.
Finally, the Database window *MUST* be open for any database scripting to work properly. Using #DBLOAD without the database window being open just won't work. Basically, the database module is not loaded into CMUD until the database window is opened. |
|
|
|
Eiredrake Beginner
Joined: 14 Jun 2005 Posts: 15
|
Posted: Sat Jun 20, 2009 8:45 pm |
That explains some of the oddness I was seeing. i'm starting to think the easiest way to handle what i want to do is to just use some DB variables. Only problem is those aren't persisted in any so if I close a session and come back later everything is reset hence why I was using a Database.
I'll repost in a bit to show the latest madness. I didn't know about closing the window though. I generally keep it closed since I don't use it. |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Sun Jun 21, 2009 11:49 am |
Eiredrake wrote: |
i'm starting to think the easiest way to handle what i want to do is to just use some DB variables. Only problem is those aren't persisted |
Data record variables should be saved when you exit just like all other variables. If they're not being saved, you have a problem of some kind.
Or you could just use luasql for the whole thing ;D |
|
|
|
|
|