diff --git a/doc_classes/SQLite.xml b/doc_classes/SQLite.xml index a717dff..86be2e1 100644 --- a/doc_classes/SQLite.xml +++ b/doc_classes/SQLite.xml @@ -119,6 +119,15 @@ [/codeblock] + + + + Gets the the info (specified using [method create_table]) of the table with name [code]table_name[/code]. This method is equivalent to the following query: + [codeblock] + db.query("PRAGMA table_info("+ table_name + ");") + [/codeblock] + + @@ -276,4 +285,4 @@ Same as [constant VERBOSE]. - \ No newline at end of file + diff --git a/src/gdsqlite.cpp b/src/gdsqlite.cpp index 722fc89..31dd1ac 100644 --- a/src/gdsqlite.cpp +++ b/src/gdsqlite.cpp @@ -11,6 +11,7 @@ void SQLite::_bind_methods() { ClassDB::bind_method(D_METHOD("create_table", "table_name", "table_data"), &SQLite::create_table); ClassDB::bind_method(D_METHOD("drop_table", "table_name"), &SQLite::drop_table); + ClassDB::bind_method(D_METHOD("get_table_info", "table_name"), &SQLite::get_table_info); ClassDB::bind_method(D_METHOD("backup_to", "destination"), &SQLite::backup_to); ClassDB::bind_method(D_METHOD("restore_from", "source"), &SQLite::restore_from); @@ -487,6 +488,14 @@ bool SQLite::drop_table(const String &p_name) { return query(query_string); } +bool SQLite::get_table_info(const String &p_name) { + String query_string; + /* Create SQL statement */ + query_string = "PRAGMA table_info(" + p_name + ");"; + + return query(query_string); +} + bool SQLite::backup_to(String destination_path) { destination_path = ProjectSettings::get_singleton()->globalize_path(destination_path.strip_edges()); CharString dummy_path = destination_path.utf8(); @@ -1197,4 +1206,4 @@ int SQLite::load_extension(const String &p_path, const String &entrypoint) { } return rc; -} \ No newline at end of file +} diff --git a/src/gdsqlite.h b/src/gdsqlite.h index a579999..f9d2ce9 100644 --- a/src/gdsqlite.h +++ b/src/gdsqlite.h @@ -73,6 +73,7 @@ class SQLite : public RefCounted { bool create_table(const String &p_name, const Dictionary &p_table_dict); bool drop_table(const String &p_name); + bool get_table_info(const String &p_name); bool backup_to(String destination_path); bool restore_from(String source_path);