How can I access an SQL database from my script?
Accessing an SQL database
Moderator: andrew
Forum rules
Always indicate your operating system and QCAD version.
Attach drawing files, scripts and screenshots.
Post one question per topic.
Always indicate your operating system and QCAD version.
Attach drawing files, scripts and screenshots.
Post one question per topic.
Accessing an SQL database
From a QCAD user:
Re: Accessing an SQL database
The QCAD script interface provides access to databased through the Qt SQL module (QSqlDatabase, QSqlQuery, etc.).
This example show how to create a new database using the included SQLite driver:
For more information about the Qt SQL module, please refer to the Qt web site at:
https://doc.qt.io/qt-5/qtsql-module.html
This example show how to create a new database using the included SQLite driver:
Code: Select all
var db = QSqlDatabase.addDatabase("QSQLITE", "MyConnection");
db.setDatabaseName("mysql.sql");
db.open();
db.transaction();
var query = new QSqlQuery(db);
var ret = query.exec("CREATE TABLE IF NOT EXISTS MyTable (id INTEGER)");
db.commit();
https://doc.qt.io/qt-5/qtsql-module.html