Jump to content

TXT->SQL Converter


Euphy

Recommended Posts


  • Group:  Members
  • Topic Count:  72
  • Topics Per Day:  0.02
  • Content Count:  2997
  • Reputation:   1130
  • Joined:  05/27/12
  • Last Seen:  

@Lighta has updated and extended trunk/tools/item_db.pl to convert the entire Pre-Renewal and Renewal item databases. All Script/DB Developers will likely be using this tool from this point forward to update our SQL files.

The new script: http://pastebin.com/AwXBYEii

Perl, if you don't have it: http://www.perl.org/get.html

To run the script, specify an input, output, target, and table. For example:

item_db.pl --i=item_db.txt --o=item_db_re.sql --t=re --table=item_db_re
The output:

item_db_re.sql

Current file: trunk/sql-files/item_db_re.sql

If you diff the files against each other, you'll notice that some null fields differ in how they're displayed - we currently have different defaults for each item type, whereas the converter uses a single array for all defaults. Once imported into the SQL database, there are no differences between the previous and new displays.

Please post your opinion (even if you don't care!) regarding the change in formatting. We'll be following through with this shortly unless people disagree.

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  32
  • Topics Per Day:  0.01
  • Content Count:  247
  • Reputation:   207
  • Joined:  10/23/12
  • Last Seen:  

Sounds good to me.  You have my vote.

Link to comment
Share on other sites


  • Group:  Developer
  • Topic Count:  48
  • Topics Per Day:  0.01
  • Content Count:  1443
  • Reputation:   337
  • Joined:  10/17/12
  • Last Seen:  

No problems from what I see

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  16
  • Topics Per Day:  0.00
  • Content Count:  737
  • Reputation:   216
  • Joined:  11/29/11
  • Last Seen:  

--table is optional =),

is just to specify wich name you want for the table like --table=item_db2 will create the sql "struct" and "replace into" for item_db2 as target.

If not specifyed like :

"item_db.pl --i=item_db.txt --o=item_db_re.sql --t=re"

the default "item_db_re" will be used as tablename.

 

@Euphy

if( $sHelp ) {
                print "ERROR: Incorect option specified. Available options:\n"
This is actually not always an error as you could have asked what option are present with :

"item_db.pl --help"

to print out this help menu.

 

For the default columns idk if you want and if we should add another option to either use the one defined in the script or just full with NULL ex:

"item_db.pl --i=item_db.txt --o=item_db_re.sql --t=re --d=0"

Could have turn off script default and fill all empty column with NULL.

 

The script can be extended again to support the other database, will probably just need to declare another subtype=item/mob and declare tableformat into BuildDataForType section.

Well this and this spliting :

if ($ligne =~ $line_format) {
     @champ = ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22);
}
As he only support 22 columns right now.
  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  72
  • Topics Per Day:  0.02
  • Content Count:  2997
  • Reputation:   1130
  • Joined:  05/27/12
  • Last Seen:  

Implemented in r17371. Leaving the topic open for further discussion.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  74
  • Topics Per Day:  0.02
  • Content Count:  420
  • Reputation:   89
  • Joined:  01/30/12
  • Last Seen:  

I made a generic converter for myself, before this release got into my knowledge. I used if mainly for item_db-s, but it should work with others as well (monster/monster skill/etc..). It's just a dumb string chopper, gui application, with some manual copy-paste requirement, so don't expect much.

 

I don't claim any rights, I'm just posting this to give some help, so if someone finds it useful, then feel free to use it :)

 

Needs Java and an OS with GUI. Pretty self explaining, but for info on how to use, click on the Info menu.

 

Executable: http://ngc1999.ragna.ro/sources/raccoonv/rACCOONv.jar

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  16
  • Topics Per Day:  0.00
  • Content Count:  737
  • Reputation:   216
  • Joined:  11/29/11
  • Last Seen:  

@Antares, I look you converter quickly but you need to escape string.

eg :

REPLACE INTO `item_db_re` VALUES (528,'Monster\'s_Feed','Monster\'s Feed',0,60,NULL,150,NULL,NULL,NULL,NULL,0xFFFFFFFF,7,2,NULL,NULL,NULL,NULL,NULL,'itemheal rand(72,108),0;',NULL,NULL);

or

REPLACE INTO `item_db_re` VALUES (1824,'BF_Knuckle2','Brave Battle Fist',4,20,NULL,0,'30',NULL,1,0,0x00008100,7,2,2,3,'80',1,12,'bonus bStr,2; bonus bInt,1; bonus2 bAddRace,RC_DemiHuman,95; bonus2 bVariableCastrate,"MO_EXTREMITYFIST",-25; autobonus "{ bonus2 bVariableCastrate,\\\"MO_EXTREMITYFIST\\\",-100; }",50,6000,BF_WEAPON,"{ specialeffect2 EF_SUFFRAGIUM; }"; bonus bUnbreakableWeapon,0;',NULL,NULL);

Otherwise there minor stuff like you completly discarding comments //, dunno if wouldn't be better to turn them into sql comment #, no leaning and trailing white space removal.

But in other hand is more flexible as he can convert all atm.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  74
  • Topics Per Day:  0.02
  • Content Count:  420
  • Reputation:   89
  • Joined:  01/30/12
  • Last Seen:  

Thx for the head's up. I forgot the quad backslash.... regex in java results in silly amount of backslashes when I want to escape something in the output :D

 

Fixd whitespaces as well.

 

I didn't turn escaped lines into sql escaped lines, because escaped data lines are not parsed, and would lead into putting commented raw txt lines between sql codes.

 

I updated the file, so the link is the same.

 

Pz let me know if you find something more :)

 

 

//The second type of escape is not done yet, I'll fix that as well soon.

////Ok, it's done now. So again, if anyone finds anything else let me know :)

Edited by Antares
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  72
  • Topics Per Day:  0.02
  • Content Count:  2997
  • Reputation:   1130
  • Joined:  05/27/12
  • Last Seen:  

Finished in r17376, thanks again to Lighta!

The tool has been extended to cover all the SQL databases.

Link to comment
Share on other sites

×
×
  • Create New...