ソースを参照

Adds SQL to TXT dump (#5527)

* Fixes #5499.
* Adds some SQL to TXT dump queries to allow conversion of custom SQL items to TXT and then YAML.
Thanks to @RagnaWay's suggestion!
Aleos 4 年 前
コミット
b49e7a0dd9

+ 8 - 0
sql-files/README.md

@@ -64,3 +64,11 @@ The `tools` folder contains some simple adjustments if needed for an administrat
 * convert_engine_innodb.sql - Converts the SQL table engine setting to InnoDB.
 * convert_engine_myiasm.sql - Converts the SQL table engine setting to MyISAM.
 * convert_passwords.sql - Converts the login table's password value to MD5.
+
+Useful tools for converting custom SQL items to TXT and then YAML. Please adjust the `INTO OUTFILE` in the query to a desired location.
+To run these queries the user requires the [FILE](https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_file) permission. It's also required to either [set or disable](https://computingforgeeks.com/how-to-solve-mysql-server-is-running-with-the-secure-file-priv-error/) the `secure-file-priv`. 
+
+* item_db_re_to_txt.sql - Dumps the __renewal__ item data table to TXT format.
+* item_db_to_txt.sql - Dumps the __pre-renewal__ item data table to TXT format.
+* item_db2_re_to_txt.sql - Dumps the __renewal__ item data table (import) to TXT format.
+* item_db2_to_txt.sql - Dumps the __pre-renewal__ item data table (import) to TXT format.

+ 24 - 0
sql-files/tools/item_db2_re_to_txt.sql

@@ -0,0 +1,24 @@
+#
+# Exports the `item_db2_re` to TXT format
+#
+
+SELECT
+	`id`, `name_english`, `name_japanese`, `type`, IFNULL(`price_buy`, ''), IFNULL(`price_sell`, ''), IFNULL(`weight`, ''), IFNULL(`atk:matk`, ''), IFNULL(`defence`, ''), IFNULL(`range`, ''), IFNULL(`slots`, ''), IFNULL(`equip_jobs`, ''), IFNULL(`equip_upper`, ''), IFNULL(`equip_genders`, ''), IFNULL(`equip_locations`, ''), IFNULL(`weapon_level`, ''), IFNULL(`equip_level`, ''), IFNULL(`refineable`, ''), IFNULL(`view`, ''),
+	CASE
+		WHEN ISNULL(`script`) THEN "{}"
+		ELSE CONCAT("{ ", `script`, " }")
+	END,
+	CASE
+		WHEN ISNULL(`equip_script`) THEN "{}"
+		ELSE CONCAT("{ ", `equip_script`, " }")
+	END,
+	CASE
+		WHEN ISNULL(`unequip_script`) THEN "{}"
+		ELSE CONCAT("{ ", `unequip_script`, " }")
+	END
+FROM `item_db2_re`
+INTO OUTFILE 'C:/item_db2_re.txt'
+FIELDS OPTIONALLY ENCLOSED BY ''
+TERMINATED BY ','
+ESCAPED BY ''
+LINES TERMINATED BY '\r\n';

+ 24 - 0
sql-files/tools/item_db2_to_txt.sql

@@ -0,0 +1,24 @@
+#
+# Exports the `item_db2` to TXT format
+#
+
+SELECT
+	`id`, `name_english`, `name_japanese`, `type`, IFNULL(`price_buy`, ''), IFNULL(`price_sell`, ''), IFNULL(`weight`, ''), IFNULL(`attack`, ''), IFNULL(`defence`, ''), IFNULL(`range`, ''), IFNULL(`slots`, ''), IFNULL(`equip_jobs`, ''), IFNULL(`equip_upper`, ''), IFNULL(`equip_genders`, ''), IFNULL(`equip_locations`, ''), IFNULL(`weapon_level`, ''), IFNULL(`equip_level`, ''), IFNULL(`refineable`, ''), IFNULL(`view`, ''),
+	CASE
+		WHEN ISNULL(`script`) THEN "{}"
+		ELSE CONCAT("{ ", `script`, " }")
+	END,
+	CASE
+		WHEN ISNULL(`equip_script`) THEN "{}"
+		ELSE CONCAT("{ ", `equip_script`, " }")
+	END,
+	CASE
+		WHEN ISNULL(`unequip_script`) THEN "{}"
+		ELSE CONCAT("{ ", `unequip_script`, " }")
+	END
+FROM `item_db2`
+INTO OUTFILE 'C:/item_db2.txt'
+FIELDS OPTIONALLY ENCLOSED BY ''
+TERMINATED BY ','
+ESCAPED BY ''
+LINES TERMINATED BY '\r\n';

+ 24 - 0
sql-files/tools/item_db_re_to_txt.sql

@@ -0,0 +1,24 @@
+#
+# Exports the `item_db_re` to TXT format
+#
+
+SELECT
+	`id`, `name_english`, `name_japanese`, `type`, IFNULL(`price_buy`, ''), IFNULL(`price_sell`, ''), IFNULL(`weight`, ''), IFNULL(`atk:matk`, ''), IFNULL(`defence`, ''), IFNULL(`range`, ''), IFNULL(`slots`, ''), IFNULL(`equip_jobs`, ''), IFNULL(`equip_upper`, ''), IFNULL(`equip_genders`, ''), IFNULL(`equip_locations`, ''), IFNULL(`weapon_level`, ''), IFNULL(`equip_level`, ''), IFNULL(`refineable`, ''), IFNULL(`view`, ''),
+	CASE
+		WHEN ISNULL(`script`) THEN "{}"
+		ELSE CONCAT("{ ", `script`, " }")
+	END,
+	CASE
+		WHEN ISNULL(`equip_script`) THEN "{}"
+		ELSE CONCAT("{ ", `equip_script`, " }")
+	END,
+	CASE
+		WHEN ISNULL(`unequip_script`) THEN "{}"
+		ELSE CONCAT("{ ", `unequip_script`, " }")
+	END
+FROM `item_db_re`
+INTO OUTFILE 'C:/item_db_re.txt'
+FIELDS OPTIONALLY ENCLOSED BY ''
+TERMINATED BY ','
+ESCAPED BY ''
+LINES TERMINATED BY '\r\n';

+ 24 - 0
sql-files/tools/item_db_to_txt.sql

@@ -0,0 +1,24 @@
+#
+# Exports the `item_db` to TXT format
+#
+
+SELECT
+	`id`, `name_english`, `name_japanese`, `type`, IFNULL(`price_buy`, ''), IFNULL(`price_sell`, ''), IFNULL(`weight`, ''), IFNULL(`attack`, ''), IFNULL(`defence`, ''), IFNULL(`range`, ''), IFNULL(`slots`, ''), IFNULL(`equip_jobs`, ''), IFNULL(`equip_upper`, ''), IFNULL(`equip_genders`, ''), IFNULL(`equip_locations`, ''), IFNULL(`weapon_level`, ''), IFNULL(`equip_level`, ''), IFNULL(`refineable`, ''), IFNULL(`view`, ''),
+	CASE
+		WHEN ISNULL(`script`) THEN "{}"
+		ELSE CONCAT("{ ", `script`, " }")
+	END,
+	CASE
+		WHEN ISNULL(`equip_script`) THEN "{}"
+		ELSE CONCAT("{ ", `equip_script`, " }")
+	END,
+	CASE
+		WHEN ISNULL(`unequip_script`) THEN "{}"
+		ELSE CONCAT("{ ", `unequip_script`, " }")
+	END
+FROM `item_db`
+INTO OUTFILE 'C:/item_db.txt'
+FIELDS OPTIONALLY ENCLOSED BY ''
+TERMINATED BY ','
+ESCAPED BY ''
+LINES TERMINATED BY '\r\n';