April 20, 2011Qt SQL moduleSAINT adaptations & workaroundsAndré Somers  |  1
André Somers  |  2  |  SAINT database layer : Design and RationaleDatabase use caseSituation:All data stored in Relational Database, one database foreachstudyOriginallyusingMS AccessMaking database independent; first target MySqlProblem: SQL dialectsDifferent names and limitationsfor data typesSolution: No actual SQL code in codeQuery textsgeneratedby (extended) SQL driverforQt
André Somers  |  3  |  SAINT database layer : Design and RationaleQt & DatabasesQt drivers do not support DDL by defaultNo way to generate SQL to manipulate data structuresSolution: custom extension to Qt SQL driver modelQt SQL drivers are pluginsNew drivers subclassed from standard driver (so they can still be used where you’d otherwise use other drivers), but have an extended base to allow for more functionality.
André Somers  |  4  |  SAINT database layer : Design and RationaleSAINT extended Qt DB driversStandard QtSAINT extended driversQSqlDriverSqlDriverExtQODBCDriverAccessDriverQMySqlDriverMySqlDriverOther driverFuture other drivers
André Somers  |  5  |  SAINT database layer : Design and RationaleSAINT extended Qt DB drivers 2//createtable (simplified)QSqlRecordrecord;foreach (QSqlField field, table->fieldList) {record.append(field);}foreach(QStringrelationName, table->fkRelations) {Relation* rel = m_relations.value(relationName);QSqlFieldfkField(QString("%1_%2")       .arg(tableName(rel->tableOne)) 	      .arg(rel->fieldOne), QVariant::UInt);fkField.setLength(30);record.append(fkField);}sql= m_sqlDriver->sqlStatement(SqlDriverExt::CreateTableStatement, table->name, record);QSqlQueryquery(sql, m_db);Construct object-based representation of the desired table structureSqlDriverExt instanceOne of the new sqlStatement typesUse representation to create SQL
New DDL statement typesCreateTableStatementAlterTableAddFieldStatementAlterTableDropFieldStatementAlterTableModifyFieldStatementDropTableStatementCreateViewStatementDropViewStatementCreateIndexStatementDropDatabaseStatement
Other added featuresCreate-if-not-existsUse database templatesList databases on a serverRAII class for transactionsReturn information on installed drivers:Human readable nameIconServer or file basedDefault settings for UI (like standard port number)Workarounds for some smaller Qt SQL issues
Unifying the UIGoals:Unified way to select a database independent of the typeKeep history of recently used databases for easy re-selectingRe-usable components for selection for integration in all toolsTreat all the information on a database as a single unit of informationAvoid special-casing for different types of databases
Resulting UIAndré Somers  |  9  | SAINT database layer: design and rationaleDrop-down box for easy re-selecting recently used databasesAccess to more databasesList is provided by proxy on custom modelIcons representing database typeUnique alias for each used database
Resulting UI (cont)André Somers  |  10  | SAINT database layer: design and rationaleTabs to switch between already used databases and other databasesSortableFilter on alias Human-readable dates and times of last use
Resulting UI (cont)André Somers  |  11  | SAINT database layer: design and rationaleDrop down with discovered database driversFile selector dialogRecently used filesDatabase alias (auto suggested)
Resulting UI (cont)André Somers  |  12  | SAINT database layer: design and rationaleExisting databases on selected server
DatabaseDescription classPropertiesQString driverNameQString fileNameQString hostQString hostAliasint port QString userQString passwordQString databaseNameQString aliasQDateTime lastAccessMethodsbool exists()bool isValid()State state()QSqlDatabase sqlDatabase(const Qstring&)SqlDriverExt::DriverInfo driverInfo()bool dropDatabase()OperatorsQDataStream& operator<<(QDataStream&, const DatabaseDescription&)QDataStream& operator>>(QDataStream&, DatabaseDescription&)
TransactionsPerfect candidate for RAIICreating an instance on a QSqlDatabase begins a transactionExplicitly call commit() method to mark successful end of transactionIf goes out of scope before commit is called, it tries a roll-back.André Somers  |  14  | SAINT database layer: design and rationale
Transaction RAII classclassSqltransaction {public:explicitSqlTransaction(QSqlDriver* driver);    ~SqlTransaction();QSqlDriver* driver() {return m_driver;}inlineboolinTransaction() {return m_inTransaction;}inlineboolactive() {return m_inTransaction;}boolrollBack();boolcommit();boolcommitOrRollBack();boolsupported();private:    //...};André Somers  |  15  | SAINT database layer: design and rationale
Succes?Almost all database-dependent code has been removed from the code that is not part of the database layer presented.Still some pieces of code like this:Separate database template files are still neededAll in all: pretty good, and certainly workableAndré Somers  |  16  | SAINT database layer: design and rationale
Remaining problemsDocumentation in Qt is lacking on thisApproach is quite low-level. Higher level would be niceQuery construction primitives are very basic:No sortingOnly = operator in WHERE statementsNo limitingNot asyncAndré Somers  |  17  | SAINT database layer: design and rationale
ThanksThank you for your attention.Questions & Discussion:What issues remain for you?André Somers  |  18  | SAINT database layer: design and rationale
André Somers  |  19  | SAINT database layer: design and rationale
André Somers  |  20  | SAINT database layer: design and rationale
Bio-energy, 2008-2009, 8414 publications, approx. 187400 links, in Gephi using Force Atlas. Image: E. Horlings.

More Related Content

PDF
Microsoft SQL Server 2012 Components and Tools (Quick Overview) - Rev 1.3
PPTX
SQLite - Overview
PPT
Sqlite
PDF
Introduction to SQLite: The Most Popular Database in the World
PPTX
Sql 2016 - What's New
PPTX
MongoDB-SESION01
PPTX
Sqlite
PPTX
Entity framework introduction sesion-1
Microsoft SQL Server 2012 Components and Tools (Quick Overview) - Rev 1.3
SQLite - Overview
Sqlite
Introduction to SQLite: The Most Popular Database in the World
Sql 2016 - What's New
MongoDB-SESION01
Sqlite
Entity framework introduction sesion-1

What's hot (20)

PDF
Using extended events for troubleshooting sql server
PPT
Higher Productivity With Ase
PDF
SQL Server 2019 ctp2.2
PPTX
Microsoft's Hadoop Story
PPTX
Taming the Data Science Monster with A New ‘Sword’ – U-SQL
PPTX
Comparison of dbms
PPTX
Introducing U-SQL (SQLPASS 2016)
PDF
Introduction to datomic
PPTX
U-SQL Intro (SQLBits 2016)
PPTX
U-SQL Meta Data Catalog (SQLBits 2016)
PPTX
U-SQL User-Defined Operators (UDOs) (SQLBits 2016)
PPTX
Spring Data Cassandra
PPT
Ssis 2008
PPTX
Oracle OpenWo2014 review part 03 three_paa_s_database
PPTX
The Road to U-SQL: Experiences in Language Design (SQL Konferenz 2017 Keynote)
PDF
PPT
1\9.SSIS 2008R2_Training - Introduction to SSIS
PDF
MOUG17: How to Build Multi-Client APEX Applications
PPTX
Cloud architectural patterns and Microsoft Azure tools
PPTX
05 entity framework
Using extended events for troubleshooting sql server
Higher Productivity With Ase
SQL Server 2019 ctp2.2
Microsoft's Hadoop Story
Taming the Data Science Monster with A New ‘Sword’ – U-SQL
Comparison of dbms
Introducing U-SQL (SQLPASS 2016)
Introduction to datomic
U-SQL Intro (SQLBits 2016)
U-SQL Meta Data Catalog (SQLBits 2016)
U-SQL User-Defined Operators (UDOs) (SQLBits 2016)
Spring Data Cassandra
Ssis 2008
Oracle OpenWo2014 review part 03 three_paa_s_database
The Road to U-SQL: Experiences in Language Design (SQL Konferenz 2017 Keynote)
1\9.SSIS 2008R2_Training - Introduction to SSIS
MOUG17: How to Build Multi-Client APEX Applications
Cloud architectural patterns and Microsoft Azure tools
05 entity framework
Ad

Viewers also liked (8)

PDF
Data in a Cloud - Introduction to Qt Cloud Services
PDF
Optimizing Performance in Qt-Based Applications
PDF
CapSite 2011 U.S. HIE Study
PDF
Usage Note of Qt ODBC Database Access on Linux
PPTX
Databases in Qt
PPT
Qt Technical Presentation
PDF
Scripting Your Qt Application
ODP
Qt 5 - C++ and Widgets
Data in a Cloud - Introduction to Qt Cloud Services
Optimizing Performance in Qt-Based Applications
CapSite 2011 U.S. HIE Study
Usage Note of Qt ODBC Database Access on Linux
Databases in Qt
Qt Technical Presentation
Scripting Your Qt Application
Qt 5 - C++ and Widgets
Ad

Similar to Sql session qt cs (20)

PPT
Sql server basics
PPTX
SQL Azure the database in the cloud
PPTX
Data Handning with Sqlite for Android
PPT
SQL Server 2008 for Developers
PDF
SQLSaturday#290_Kiev_WindowsAzureDatabaseForBeginners
PPTX
android sqlite
PPTX
PASS Summit - SQL Server 2017 Deep Dive
PPTX
Azure for ug
PPTX
Sql Sever Presentation.pptx
PDF
KoprowskiT_SQLSat230_Rheinland_SQLAzure-fromPlantoBackuptoCloud
PPTX
Sql azure dec_2010 Lynn & Ike
PPTX
What’s new in SQL Server 2017
PPTX
Brk2051 sql server on linux and docker
PPTX
PDF
Microsoft SQL server 2017 Level 300 technical deck
PDF
SQLSaturday#290_Kiev_AdHocMaintenancePlansForBeginners
PDF
Serverless Data Platform
PPTX
Chapter_2_Network_Operating_System_NOS_and_Windows_Network_Concepts.pptx
PPTX
Sky High With Azure
Sql server basics
SQL Azure the database in the cloud
Data Handning with Sqlite for Android
SQL Server 2008 for Developers
SQLSaturday#290_Kiev_WindowsAzureDatabaseForBeginners
android sqlite
PASS Summit - SQL Server 2017 Deep Dive
Azure for ug
Sql Sever Presentation.pptx
KoprowskiT_SQLSat230_Rheinland_SQLAzure-fromPlantoBackuptoCloud
Sql azure dec_2010 Lynn & Ike
What’s new in SQL Server 2017
Brk2051 sql server on linux and docker
Microsoft SQL server 2017 Level 300 technical deck
SQLSaturday#290_Kiev_AdHocMaintenancePlansForBeginners
Serverless Data Platform
Chapter_2_Network_Operating_System_NOS_and_Windows_Network_Concepts.pptx
Sky High With Azure

Recently uploaded (20)

PPT
Module 1.ppt Iot fundamentals and Architecture
PDF
OpenACC and Open Hackathons Monthly Highlights July 2025
PDF
UiPath Agentic Automation session 1: RPA to Agents
PDF
A contest of sentiment analysis: k-nearest neighbor versus neural network
PDF
sbt 2.0: go big (Scala Days 2025 edition)
PPTX
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
PPTX
Microsoft Excel 365/2024 Beginner's training
PDF
A review of recent deep learning applications in wood surface defect identifi...
PDF
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
PDF
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
PDF
sustainability-14-14877-v2.pddhzftheheeeee
PPT
What is a Computer? Input Devices /output devices
PPTX
Final SEM Unit 1 for mit wpu at pune .pptx
PDF
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
PDF
CloudStack 4.21: First Look Webinar slides
PDF
A comparative study of natural language inference in Swahili using monolingua...
PDF
Hindi spoken digit analysis for native and non-native speakers
PPTX
AI IN MARKETING- PRESENTED BY ANWAR KABIR 1st June 2025.pptx
PDF
The influence of sentiment analysis in enhancing early warning system model f...
PDF
Getting started with AI Agents and Multi-Agent Systems
Module 1.ppt Iot fundamentals and Architecture
OpenACC and Open Hackathons Monthly Highlights July 2025
UiPath Agentic Automation session 1: RPA to Agents
A contest of sentiment analysis: k-nearest neighbor versus neural network
sbt 2.0: go big (Scala Days 2025 edition)
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
Microsoft Excel 365/2024 Beginner's training
A review of recent deep learning applications in wood surface defect identifi...
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
sustainability-14-14877-v2.pddhzftheheeeee
What is a Computer? Input Devices /output devices
Final SEM Unit 1 for mit wpu at pune .pptx
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
CloudStack 4.21: First Look Webinar slides
A comparative study of natural language inference in Swahili using monolingua...
Hindi spoken digit analysis for native and non-native speakers
AI IN MARKETING- PRESENTED BY ANWAR KABIR 1st June 2025.pptx
The influence of sentiment analysis in enhancing early warning system model f...
Getting started with AI Agents and Multi-Agent Systems

Sql session qt cs

  • 1. April 20, 2011Qt SQL moduleSAINT adaptations & workaroundsAndré Somers | 1
  • 2. André Somers | 2 | SAINT database layer : Design and RationaleDatabase use caseSituation:All data stored in Relational Database, one database foreachstudyOriginallyusingMS AccessMaking database independent; first target MySqlProblem: SQL dialectsDifferent names and limitationsfor data typesSolution: No actual SQL code in codeQuery textsgeneratedby (extended) SQL driverforQt
  • 3. André Somers | 3 | SAINT database layer : Design and RationaleQt & DatabasesQt drivers do not support DDL by defaultNo way to generate SQL to manipulate data structuresSolution: custom extension to Qt SQL driver modelQt SQL drivers are pluginsNew drivers subclassed from standard driver (so they can still be used where you’d otherwise use other drivers), but have an extended base to allow for more functionality.
  • 4. André Somers | 4 | SAINT database layer : Design and RationaleSAINT extended Qt DB driversStandard QtSAINT extended driversQSqlDriverSqlDriverExtQODBCDriverAccessDriverQMySqlDriverMySqlDriverOther driverFuture other drivers
  • 5. André Somers | 5 | SAINT database layer : Design and RationaleSAINT extended Qt DB drivers 2//createtable (simplified)QSqlRecordrecord;foreach (QSqlField field, table->fieldList) {record.append(field);}foreach(QStringrelationName, table->fkRelations) {Relation* rel = m_relations.value(relationName);QSqlFieldfkField(QString("%1_%2") .arg(tableName(rel->tableOne)) .arg(rel->fieldOne), QVariant::UInt);fkField.setLength(30);record.append(fkField);}sql= m_sqlDriver->sqlStatement(SqlDriverExt::CreateTableStatement, table->name, record);QSqlQueryquery(sql, m_db);Construct object-based representation of the desired table structureSqlDriverExt instanceOne of the new sqlStatement typesUse representation to create SQL
  • 6. New DDL statement typesCreateTableStatementAlterTableAddFieldStatementAlterTableDropFieldStatementAlterTableModifyFieldStatementDropTableStatementCreateViewStatementDropViewStatementCreateIndexStatementDropDatabaseStatement
  • 7. Other added featuresCreate-if-not-existsUse database templatesList databases on a serverRAII class for transactionsReturn information on installed drivers:Human readable nameIconServer or file basedDefault settings for UI (like standard port number)Workarounds for some smaller Qt SQL issues
  • 8. Unifying the UIGoals:Unified way to select a database independent of the typeKeep history of recently used databases for easy re-selectingRe-usable components for selection for integration in all toolsTreat all the information on a database as a single unit of informationAvoid special-casing for different types of databases
  • 9. Resulting UIAndré Somers | 9 | SAINT database layer: design and rationaleDrop-down box for easy re-selecting recently used databasesAccess to more databasesList is provided by proxy on custom modelIcons representing database typeUnique alias for each used database
  • 10. Resulting UI (cont)André Somers | 10 | SAINT database layer: design and rationaleTabs to switch between already used databases and other databasesSortableFilter on alias Human-readable dates and times of last use
  • 11. Resulting UI (cont)André Somers | 11 | SAINT database layer: design and rationaleDrop down with discovered database driversFile selector dialogRecently used filesDatabase alias (auto suggested)
  • 12. Resulting UI (cont)André Somers | 12 | SAINT database layer: design and rationaleExisting databases on selected server
  • 13. DatabaseDescription classPropertiesQString driverNameQString fileNameQString hostQString hostAliasint port QString userQString passwordQString databaseNameQString aliasQDateTime lastAccessMethodsbool exists()bool isValid()State state()QSqlDatabase sqlDatabase(const Qstring&)SqlDriverExt::DriverInfo driverInfo()bool dropDatabase()OperatorsQDataStream& operator<<(QDataStream&, const DatabaseDescription&)QDataStream& operator>>(QDataStream&, DatabaseDescription&)
  • 14. TransactionsPerfect candidate for RAIICreating an instance on a QSqlDatabase begins a transactionExplicitly call commit() method to mark successful end of transactionIf goes out of scope before commit is called, it tries a roll-back.André Somers | 14 | SAINT database layer: design and rationale
  • 15. Transaction RAII classclassSqltransaction {public:explicitSqlTransaction(QSqlDriver* driver); ~SqlTransaction();QSqlDriver* driver() {return m_driver;}inlineboolinTransaction() {return m_inTransaction;}inlineboolactive() {return m_inTransaction;}boolrollBack();boolcommit();boolcommitOrRollBack();boolsupported();private: //...};André Somers | 15 | SAINT database layer: design and rationale
  • 16. Succes?Almost all database-dependent code has been removed from the code that is not part of the database layer presented.Still some pieces of code like this:Separate database template files are still neededAll in all: pretty good, and certainly workableAndré Somers | 16 | SAINT database layer: design and rationale
  • 17. Remaining problemsDocumentation in Qt is lacking on thisApproach is quite low-level. Higher level would be niceQuery construction primitives are very basic:No sortingOnly = operator in WHERE statementsNo limitingNot asyncAndré Somers | 17 | SAINT database layer: design and rationale
  • 18. ThanksThank you for your attention.Questions & Discussion:What issues remain for you?André Somers | 18 | SAINT database layer: design and rationale
  • 19. André Somers | 19 | SAINT database layer: design and rationale
  • 20. André Somers | 20 | SAINT database layer: design and rationale
  • 21. Bio-energy, 2008-2009, 8414 publications, approx. 187400 links, in Gephi using Force Atlas. Image: E. Horlings.