https://wiki.nexusmods.com/api.php?action=feedcontributions&user=LukasLuftwandler&feedformat=atomNexus Mods Wiki - User contributions [en]2024-03-29T06:30:20ZUser contributionsMediaWiki 1.30.1https://wiki.nexusmods.com/index.php?title=Setting_up_Database&diff=73593Setting up Database2019-11-14T21:18:04Z<p>LukasLuftwandler: for me psql.exe didnt work, but cmd worked fine. just like in the kdc forums: https://forum.kingdomcomerpg.com/t/wip-pre-rls-un-official-install-guide-v1-modding-tools-1-9-3-postgresql-11/67044</p>
<hr />
<div><br />
= Database =<br />
<br />
The Game database contains all the game data, such as items, dialogues, perks, etc. The modding pack contains a dump of the game database in SQL format. In this tutorial we are going to use PostreSQL hosted locally on your computer, which the modding tools will connect to.&nbsp;<br />
<br />
First download and install PostreSQL from [https://www.postgresql.org/ their website]. (Do not install version 12, as this might cause a missing column "adsrc" error when you later run the sequences.sql script) You will also want to install the 64-bit PosgreSQL ODBC driver, which you can get from [https://odbc.postgresql.org/ https://odbc.postgresql.org/]. After install the database server should be up and running. Then we open pgAdmin (comes with the PostgreSQL package)&nbsp;tool and connect to the server. After connecting to the server we have to create a new database called&nbsp;<tt><q>ConfigDB</q></tt>&nbsp;(the name is unfortunatley hardcoded into some of the tools). When created add new <tt><q>uuid-ossp</q></tt> extention to this database.<br />
<br />
https://wiki.nexusmods.com/images/0/0c/Setting_Up_Database_image1.jpg<br />
<br />
If you do not have acces to the pgAdmin you can run this via command line using&nbsp;''psql.exe''&nbsp;(comes with PostgreSQL package) with the following commands.&nbsp;<br />
<div style="background:#000; border:1px solid #cccccc; padding:5px 10px"><tt>CREATE DATABASE ConfigDB;<br/> CREATE EXTENSION "uuid-ossp";</tt></div> <br />
Note that creating your database through the psql tool will result in stripping out the case sensitivity (ConfigDB becomes configdb). The mod tools do not appear to require precise case for the database name,&nbsp; but other SQL tools (such as running psql from the command line in the example below) might.<br />
<br />
After&nbsp;completing first step we use&nbsp;''psql.exe or cmd'' to restore the database from provided dumps.<br />
<div style="background:#000; border:1px solid #cccccc; padding:5px 10px"><br />
<tt><PostgreSQL Installation Path>/bin/psql.exe -f <KCD Installation Path>/Data_reference/modding.sql -U&nbsp;postgres –d&nbsp;ConfigDB -q&nbsp;</tt><br />
<br />
<tt><PostgreSQL Installation Path>/bin/psql.exe -f&nbsp;<KCD Installation Path>/Data_reference/public.sql -U&nbsp;postgres –d&nbsp;ConfigDB -q&nbsp;</tt><br />
</div> <br />
You will be asked for your database password again. 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 <q><tt>modding</tt></q>&nbsp;with 468 tables.&nbsp;&nbsp;<br />
<br />
&nbsp;<br />
<br />
== Autoincrement ==<br />
<br />
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, open file <tt>Data_references.sql/sequences.sql</tt> and 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 run following command:&nbsp;<br />
<div style="background:#000; border:1px solid #cccccc; padding:5px 10px"><tt><PostgreSQL Installation Path>/bin/psql.exe -f <KCD Installation Path>/Data_reference/sequences.sql -U postgres –d ConfigDB –q&nbsp;</tt></div> <br />
&nbsp;<br />
<br />
== Setting up tools&nbsp; ==<br />
<br />
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 file <q><tt>Tools/!registry/db.reg</tt></q>&nbsp; (you only need to modify the password, <tt><q>postgres</q></tt>&nbsp;is the default user) and then run it.&nbsp;All of the tools, except the Sandbox editor, use these registry keys. To get the Sandbox to connect, fill in correct connection information in <tt><q>user.cfg</q></tt>. Sandbox editor also requires an ''ODBC Driver'' to use. Install one for&nbsp;postgreSQL from [https://odbc.postgresql.org/ their&nbsp;site] (use 64-bit version).&nbsp;<br />
<br />
&nbsp;<br />
<br />
== Working with Database ==<br />
<br />
The database can be edited with any SQL client you prefer, or you can use our custom tool.&nbsp; It is a plugin for MS Excel, which simplifies editing tables by unpacking foreign keys. To use it, you need to install in from <tt><q>Tools/ExcelDbAddin2</q></tt>, 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 <tt><q>WHS DB</q></tt>.&nbsp;<br />
<br />
Any changes made to the database will be visible in the Sandbox editor (with the exception of Localization). The game, however, reads the database from XML files inside&nbsp;''Tables.pak'' or mod PAK files. To create such PAKs, use the editor’s&nbsp;[https://wiki.nexusmods.com/index.php/Modding_Tool modding window]&nbsp;.<br />
<br />
&nbsp;<br />
<br />
&nbsp;<br />
<br />
== TL;DR ==<br />
<br />
#Install PostgreSQL server. <br />
#Install ODBC driver (64bit) for PostgreSQL. <br />
#Open ''pgAdmin'', it's installed with PostgreSQL package. <br />
#Create&nbsp;''ConfigDB''&nbsp;database. <br />
#Add&nbsp;''uuid-ossp&nbsp;''extension to that database. <br />
#Edit ''Data_reference/sequences.sql&nbsp;''number 10578&nbsp;to something higher than 100000. <br />
#Migrate files&nbsp;<br/> <br/> <tt>psql.exe -f&nbsp;Data_reference/modding.sql -U&nbsp;postgres –d&nbsp;ConfigDB -q</tt><br/> <tt>psql.exe -f&nbsp;Data_reference/public.sql -U&nbsp;postgres –d&nbsp;ConfigDB -q</tt><br/> <tt>psql.exe -f Data_reference/sequences.sql -U postgres –d ConfigDB –q&nbsp;</tt><br/> &nbsp; <br />
#Configure your&nbsp;''user.cfg''&nbsp;in root directory<br/> <br/> wh_sys_SQLServer = "127.0.0.1"<br/> wh_sys_SQLDatabase = "ConfigDB"<br/> wh_sys_SQLUser = "postgres"<br/> wh_sys_SQLPassword = "'''YOUR DATABASE PASSWORD'''"<br/> wh_sys_SQLBranch = "modding"<br/> wh_sys_PreferredDB = SQL, TBL, XML<br/> wh_sys_SQLWritable = 1 <br />
#&nbsp; <br />
#Done, start editor.<br/> &nbsp; <br />
<br />
[[Category:Kingdom Come Deliverance]] [[Category:Getting Started]]</div>LukasLuftwandler