Skip to content

Commit b5146db

Browse files
committedMar 1, 2019
Use the QgsSqliteUtils system tables list in DB Manager
1 parent 0df39bd commit b5146db

File tree

4 files changed

+77
-25
lines changed

4 files changed

+77
-25
lines changed
 
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/************************************************************************
2+
* This file has been generated automatically from *
3+
* *
4+
* src/core/qgssqliteutils.h *
5+
* *
6+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
7+
************************************************************************/
8+
9+
10+
11+
12+
13+
14+
15+
class QgsSqliteUtils
16+
{
17+
%Docstring
18+
Contains utilities for working with Sqlite data sources.
19+
20+
.. versionadded:: 3.4
21+
%End
22+
23+
%TypeHeaderCode
24+
#include "qgssqliteutils.h"
25+
%End
26+
public:
27+
28+
static QString quotedString( const QString &value );
29+
%Docstring
30+
Returns a quoted string ``value``, surround by ' characters and with special
31+
characters correctly escaped.
32+
%End
33+
34+
static QString quotedIdentifier( const QString &identifier );
35+
%Docstring
36+
Returns a properly quoted version of ``identifier``.
37+
38+
.. versionadded:: 3.6
39+
%End
40+
41+
static QString quotedValue( const QVariant &value );
42+
%Docstring
43+
Returns a properly quoted and escaped version of ``value``
44+
for use in SQL strings.
45+
46+
.. versionadded:: 3.6
47+
%End
48+
49+
static QStringList systemTables();
50+
%Docstring
51+
Returns a string list of SQLite (and spatialite) system tables
52+
53+
.. versionadded:: 3.8
54+
%End
55+
};
56+
57+
/************************************************************************
58+
* This file has been generated automatically from *
59+
* *
60+
* src/core/qgssqliteutils.h *
61+
* *
62+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
63+
************************************************************************/

‎python/core/core_auto.sip

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@
120120
%Include auto_generated/qgsspatialindexkdbush.sip
121121
%Include auto_generated/qgsspatialindexkdbushdata.sip
122122
%Include auto_generated/qgssqlstatement.sip
123+
%Include auto_generated/qgssqliteutils.sip
123124
%Include auto_generated/qgsstatisticalsummary.sip
124125
%Include auto_generated/qgsstringstatisticalsummary.sip
125126
%Include auto_generated/qgsstringutils.sip

‎python/plugins/db_manager/db_plugins/spatialite/connector.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
from functools import cmp_to_key
2525

26-
from qgis.core import Qgis
26+
from qgis.core import Qgis, QgsSqliteUtils
2727
from qgis.PyQt.QtCore import QFile
2828
from qgis.PyQt.QtWidgets import QApplication
2929

@@ -171,19 +171,7 @@ def getTables(self, schema=None, add_sys_tables=False):
171171
tablenames = []
172172
items = []
173173

174-
sys_tables = ["SpatialIndex", "geom_cols_ref_sys", "geometry_columns", "geometry_columns_auth",
175-
"views_geometry_columns", "virts_geometry_columns", "spatial_ref_sys", "spatial_ref_sys_all", "spatial_ref_sys_aux",
176-
"sqlite_sequence", "tableprefix_metadata", "tableprefix_rasters",
177-
"layer_params", "layer_statistics", "layer_sub_classes", "layer_table_layout",
178-
"pattern_bitmaps", "symbol_bitmaps", "project_defs", "raster_pyramids",
179-
"sqlite_stat1", "sqlite_stat2", "spatialite_history",
180-
"geometry_columns_field_infos",
181-
"geometry_columns_statistics", "geometry_columns_time",
182-
"sql_statements_log", "vector_layers", "vector_layers_auth", "vector_layers_field_infos", "vector_layers_statistics",
183-
"views_geometry_columns_auth", "views_geometry_columns_field_infos", "views_geometry_columns_statistics",
184-
"virts_geometry_columns_auth", "virts_geometry_columns_field_infos", "virts_geometry_columns_statistics",
185-
"virts_layer_statistics", "views_layer_statistics", "ElementaryGeometries"
186-
]
174+
sys_tables = QgsSqliteUtils.systemTables()
187175

188176
try:
189177
vectors = self.getVectorTables(schema)

‎src/core/qgssqliteutils.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
#ifndef QGSSQLITEUTILS_H
1919
#define QGSSQLITEUTILS_H
2020

21-
#define SIP_NO_FILE
22-
2321
#include "qgis_core.h"
2422
#include "qgis_sip.h"
2523

@@ -30,6 +28,8 @@ struct sqlite3;
3028
struct sqlite3_stmt;
3129
class QVariant;
3230

31+
#ifndef SIP_RUN
32+
3333
/**
3434
* \ingroup core
3535
*
@@ -150,9 +150,17 @@ class CORE_EXPORT sqlite3_database_unique_ptr : public std::unique_ptr< sqlite3,
150150
int exec( const QString &sql, QString &errorMessage SIP_OUT ) const;
151151
};
152152

153+
/**
154+
* Wraps sqlite3_mprintf() by automatically freeing the memory.
155+
* \note not available in Python bindings.
156+
* \since QGIS 3.2
157+
*/
158+
QString CORE_EXPORT QgsSqlite3Mprintf( const char *format, ... );
159+
160+
#endif
161+
153162
/**
154163
* Contains utilities for working with Sqlite data sources.
155-
* \note not available in Python bindings
156164
* \ingroup core
157165
* \since QGIS 3.4
158166
*/
@@ -189,12 +197,4 @@ class CORE_EXPORT QgsSqliteUtils
189197
static QStringList systemTables();
190198
};
191199

192-
/**
193-
* Wraps sqlite3_mprintf() by automatically freeing the memory.
194-
* \note not available in Python bindings.
195-
* \since QGIS 3.2
196-
*/
197-
QString CORE_EXPORT QgsSqlite3Mprintf( const char *format, ... );
198-
199-
200200
#endif // QGSSQLITEUTILS_H

0 commit comments

Comments
 (0)
Please sign in to comment.