logo logo

 Back to main page

The NWNX Community Forum

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Switching to NWNX/mySQL - Converting Data

 
Post new topic   Reply to topic    nwnx.org Forum Index -> Windows technical support
View previous topic :: View next topic  
Author Message
FunkySwerve



Joined: 02 Jun 2005
Posts: 377

PostPosted: Thu Jun 02, 2005 14:01    Post subject: Switching to NWNX/mySQL - Converting Data Reply with quote

I'm currently running a PW with MANY logins per day, with a default Bioware database extending back to 1/15/05 or so. I would like to convert the data for use with NWNX, but have no idea where to begin. Is there a tutorial covering this that I've missed? If not, could someone please give an overview of the process?
Thanks,
Funky
Back to top
View user's profile Send private message
FunkySwerve



Joined: 02 Jun 2005
Posts: 377

PostPosted: Thu Jun 02, 2005 19:27    Post subject: Reply with quote

Ok, I found the following in the aps_include file, it seems to suggest how one might go about making the switch:
[nwscript]
string GetPersistentString(object oObject, string sVarName, string sTable = "pwdata")
{
string sPlayer;
string sTag;

if (GetIsPC(oObject))
{
sPlayer = SQLEncodeSpecialChars(GetPCPlayerName(oObject));
sTag = SQLEncodeSpecialChars(GetName(oObject));
}
else
{
sPlayer = "~";
sTag = GetTag(oObject);
}

sVarName = SQLEncodeSpecialChars(sVarName);

string sSQL = "SELECT val FROM " + sTable + " WHERE player='" + sPlayer +
"' AND tag='" + sTag + "' AND name='" + sVarName + "'";
SQLExecDirect(sSQL);

if (SQLFetch() == SQL_SUCCESS)
return SQLDecodeSpecialChars(SQLGetData(1));
else
{
return "";
// If you want to convert your existing persistent data to APS, this
// would be the place to do it. The requested variable was not found
// in the database, you should
// 1) query it's value using your existing persistence functions
// 2) save the value to the database using SetPersistentString()
// 3) return the string value here.
}
}
[/nwscript]
I'm wondering if this could be used, onstartup for instance, to start sifting through database entries one at a time and converting them to SQL entries. Has anyone done something like this before?

Also, I noticed that the tutorial suggested one could just sub out one custom database command for another bt renaming the SQL commands. Am I correct in assuming that this would not work for the bioware defrault database? For instance, could I just rename the SetPersistentInt to SetCampaignInt in the include?
Thanks again,
Funky
Back to top
View user's profile Send private message
Papillon
x-man


Joined: 28 Dec 2004
Posts: 1060
Location: Germany

PostPosted: Thu Jun 02, 2005 20:28    Post subject: Reply with quote

FunkySwerve wrote:
Ok, I found the following in the aps_include file, it seems to suggest how one might go about making the switch:


That is the right place, yes.

Quote:

I'm wondering if this could be used, onstartup for instance, to start sifting through database entries one at a time and converting them to SQL entries. Has anyone done something like this before?


With the Bioware database, you can not sift through your data, since you have no way to find out which variables have been stored, i.e. you need the name of the variable to get the data. That's one of the main benefits of using SQL: you do not need to know how the variables are called, you can just tell the DB to "give you everything".

Just do as the comment in aps_include suggests: Retrieve the value from your old Bioware DB, set the resulting value using SetPersistentString, and return the value. This way, your database will convert itself over to SQL after a while.

Btw, you need to search your scripts and replace all calls to the Bioware DB with the APS counterparts.

Quote:

Also, I noticed that the tutorial suggested one could just sub out one custom database command for another bt renaming the SQL commands. Am I correct in assuming that this would not work for the bioware defrault database? For instance, could I just rename the SetPersistentInt to SetCampaignInt in the include?


You have to adjust the parameters, since Bioware's DB and NWNX use a slightly different order, but other than that, both function types behave quite similar.
_________________
Papillon
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
FunkySwerve



Joined: 02 Jun 2005
Posts: 377

PostPosted: Fri Jun 03, 2005 18:07    Post subject: Reply with quote

Papillon wrote:

Just do as the comment in aps_include suggests: Retrieve the value from your old Bioware DB, set the resulting value using SetPersistentString, and return the value. This way, your database will convert itself over to SQL after a while.

Ok, that's what I was hoping to avoid, but shouln't be difficult. Thanks for your input,
Funky
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Windows technical support All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group