Setting up Database

From Nexus Mods Wiki
Revision as of 17:43, 29 October 2019 by WarhorseStudios (talk | contribs)
Jump to: navigation, search


The Game database contains all the game data, such as items, dialogues, perks etc... The moddingpack contains a dump of the game database in SQL format. You are going to need to run a postgreSQLserver on your computer, which the moddingtools will connect to. 

First download and install postgresqlfrom their website(, then install it. DB server should automatically start. Then you need to connect to the server, create a database called “ConfigDB” (the name is unforunatelyhardcoded into some of the tools), and add extension “uuid-ossp”. 

In pgAdmin(a tool that comes with basicpostgresqlpackage): 


Or run psql.exe (also comes withpostgresql) and input following commands: 


Then run psql.exe to restore the database from provided dumps: 

psql.exe -f Data_reference/modding.sql-U postgres–d ConfigDB-q 

psql.exe -f Data_reference/public.sql-U postgres–d ConfigDB-q 

Ideally this command should run with no output of any kind (the -q switch hides all non-errors, and there should be no errors). In your database, there should be now a schema called “modding” with 468 tables. 


Some tables use autoincrement to generate IDs for new entries. If you are going to create new dialogues, you are going to need to adjust the initial value for this autoincrement to a value unique for your mod. If you don’t, your mod will clash with any other mods that also failed to set a unique value.To do this, openfileData_references.sql/sequences.sqland change the value 10578 to any value unique to your mod (ideally a value that is far enough from other mod’s values, by at least several hundreds. Since the first ids are used by KCD’s entries,choose a number higher than 100000).Then runfollowingcommand: 

psql.exe -fData_reference/sequences.sql-Upostgres–dConfigDBq 


Setting up tools 

There are several tools that work with the SQL database. Most of them require you to set up correct registry keys which they read connection information from. To do that, modify fileTools/!registry/db.reg  (you only need to modify the password, “postgres” is the default user) and then run it. All ofthe tools, except the Sandbox editor, use these registry keys. To get the Sandbox to connect, fill in correct connection information inuser.cfg.Sandbox editor also requiresanODBC driver to use. Install one for postgreSQLfromtheir site( 64-bit version). 

Working with Database

The database can be edited with any SQL client you prefer, or you can use our custom tool.  It is a plugin for MS Excel, which simplifies editing tables by unpacking foreign keys. To use it, you need to install in from Tools/ExcelDbAddin2, which installs it directly into MS Excel (it can be removed at any time in “Add or Remove programs”). It will appear as a new menu item called “WHS DB”. 

Any changes made to the database will be visible in the Sandbox editor (with the exception ofLocalization). The game, however, reads the database from XML files inside Tables.pakor mod PAK files. To create such PAKs, use the editor’s modding window .