Skip to content

Commit

Permalink
Use the QgsSqliteUtils system tables list in DB Manager
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn committed Mar 1, 2019
1 parent 0df39bd commit b5146db
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 25 deletions.
63 changes: 63 additions & 0 deletions python/core/auto_generated/qgssqliteutils.sip.in
@@ -0,0 +1,63 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgssqliteutils.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/







class QgsSqliteUtils
{
%Docstring
Contains utilities for working with Sqlite data sources.

.. versionadded:: 3.4
%End

%TypeHeaderCode
#include "qgssqliteutils.h"
%End
public:

static QString quotedString( const QString &value );
%Docstring
Returns a quoted string ``value``, surround by ' characters and with special
characters correctly escaped.
%End

static QString quotedIdentifier( const QString &identifier );
%Docstring
Returns a properly quoted version of ``identifier``.

.. versionadded:: 3.6
%End

static QString quotedValue( const QVariant &value );
%Docstring
Returns a properly quoted and escaped version of ``value``
for use in SQL strings.

.. versionadded:: 3.6
%End

static QStringList systemTables();
%Docstring
Returns a string list of SQLite (and spatialite) system tables

.. versionadded:: 3.8
%End
};

/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgssqliteutils.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
1 change: 1 addition & 0 deletions python/core/core_auto.sip
Expand Up @@ -120,6 +120,7 @@
%Include auto_generated/qgsspatialindexkdbush.sip
%Include auto_generated/qgsspatialindexkdbushdata.sip
%Include auto_generated/qgssqlstatement.sip
%Include auto_generated/qgssqliteutils.sip
%Include auto_generated/qgsstatisticalsummary.sip
%Include auto_generated/qgsstringstatisticalsummary.sip
%Include auto_generated/qgsstringutils.sip
Expand Down
16 changes: 2 additions & 14 deletions python/plugins/db_manager/db_plugins/spatialite/connector.py
Expand Up @@ -23,7 +23,7 @@

from functools import cmp_to_key

from qgis.core import Qgis
from qgis.core import Qgis, QgsSqliteUtils
from qgis.PyQt.QtCore import QFile
from qgis.PyQt.QtWidgets import QApplication

Expand Down Expand Up @@ -171,19 +171,7 @@ def getTables(self, schema=None, add_sys_tables=False):
tablenames = []
items = []

sys_tables = ["SpatialIndex", "geom_cols_ref_sys", "geometry_columns", "geometry_columns_auth",
"views_geometry_columns", "virts_geometry_columns", "spatial_ref_sys", "spatial_ref_sys_all", "spatial_ref_sys_aux",
"sqlite_sequence", "tableprefix_metadata", "tableprefix_rasters",
"layer_params", "layer_statistics", "layer_sub_classes", "layer_table_layout",
"pattern_bitmaps", "symbol_bitmaps", "project_defs", "raster_pyramids",
"sqlite_stat1", "sqlite_stat2", "spatialite_history",
"geometry_columns_field_infos",
"geometry_columns_statistics", "geometry_columns_time",
"sql_statements_log", "vector_layers", "vector_layers_auth", "vector_layers_field_infos", "vector_layers_statistics",
"views_geometry_columns_auth", "views_geometry_columns_field_infos", "views_geometry_columns_statistics",
"virts_geometry_columns_auth", "virts_geometry_columns_field_infos", "virts_geometry_columns_statistics",
"virts_layer_statistics", "views_layer_statistics", "ElementaryGeometries"
]
sys_tables = QgsSqliteUtils.systemTables()

try:
vectors = self.getVectorTables(schema)
Expand Down
22 changes: 11 additions & 11 deletions src/core/qgssqliteutils.h
Expand Up @@ -18,8 +18,6 @@
#ifndef QGSSQLITEUTILS_H
#define QGSSQLITEUTILS_H

#define SIP_NO_FILE

#include "qgis_core.h"
#include "qgis_sip.h"

Expand All @@ -30,6 +28,8 @@ struct sqlite3;
struct sqlite3_stmt;
class QVariant;

#ifndef SIP_RUN

/**
* \ingroup core
*
Expand Down Expand Up @@ -150,9 +150,17 @@ class CORE_EXPORT sqlite3_database_unique_ptr : public std::unique_ptr< sqlite3,
int exec( const QString &sql, QString &errorMessage SIP_OUT ) const;
};

/**
* Wraps sqlite3_mprintf() by automatically freeing the memory.
* \note not available in Python bindings.
* \since QGIS 3.2
*/
QString CORE_EXPORT QgsSqlite3Mprintf( const char *format, ... );

#endif

/**
* Contains utilities for working with Sqlite data sources.
* \note not available in Python bindings
* \ingroup core
* \since QGIS 3.4
*/
Expand Down Expand Up @@ -189,12 +197,4 @@ class CORE_EXPORT QgsSqliteUtils
static QStringList systemTables();
};

/**
* Wraps sqlite3_mprintf() by automatically freeing the memory.
* \note not available in Python bindings.
* \since QGIS 3.2
*/
QString CORE_EXPORT QgsSqlite3Mprintf( const char *format, ... );


#endif // QGSSQLITEUTILS_H

0 comments on commit b5146db

Please sign in to comment.