aboutsummaryrefslogtreecommitdiffstats
path: root/doc/codesnippets/doc/src/snippets/code/src_sql_kernel_qsqldriver.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'doc/codesnippets/doc/src/snippets/code/src_sql_kernel_qsqldriver.cpp')
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_sql_kernel_qsqldriver.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/doc/codesnippets/doc/src/snippets/code/src_sql_kernel_qsqldriver.cpp b/doc/codesnippets/doc/src/snippets/code/src_sql_kernel_qsqldriver.cpp
new file mode 100644
index 000000000..26f427110
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_sql_kernel_qsqldriver.cpp
@@ -0,0 +1,23 @@
+//! [0]
+db = QSqlDatabase.addDatabase("SQLITE3")
+v = QVariant(db.driver().handle())
+if v.isValid() && v.typeName() == "sqlite3*":
+ # v.data() returns a pointer to the handle
+ sqlite3 *handle = *static_cast<sqlite3 **>(v.data())
+ if handle != 0: # check that it is not NULL
+ doSomething()
+//! [0]
+
+
+//! [1]
+# Impossible to translate to python
+if (v.typeName() == "PGconn*") {
+ PGconn *handle = *static_cast<PGconn **>(v.data())
+ if (handle != 0) ...
+}
+
+if (v.typeName() == "MYSQL*") {
+ MYSQL *handle = *static_cast<MYSQL **>(v.data())
+ if (handle != 0) ...
+}
+//! [1]