Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QT SQLite with password
Forum Update on Monday, May 27th 2025

QT SQLite with password

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 4.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    Enrique82
    wrote on last edited by
    #1

    Hi, I'm starting with QT SQL. I can't open or create SQLite data base with password. I create the data base and table, but the data base is not protected and I can open whitout password.
    Also probe with mdataBase.setPassword("123"); and it does not work.

    QT SQLite supports password protection?

    QSqlDatabase mdataBase;
    mdataBase = QSqlDatabase::addDatabase("QSQLITE");
    mdataBase.setDatabaseName("h:\\bases\\dbasePW.sqlite");
    mdataBase.open("","123");    //user name "" / password"123"
    
    QString consulta;
    consulta.append("CREATE TABLE IF NOT EXISTS Persona("
                        "id INTEGER PRIMARY KEY AUTOINCREMENT,"
                        "nombre VARCHAR (100),"
                        "edad INGEGER NOT NULL"
                        ");");
    QSqlQuery crear;
    crear.prepare(consulta);
    crear.exec();
    
    

    Thanks Enrique

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #2

      Hi
      Nope. Not as far as i know.
      https://stackoverflow.com/questions/5669905/sqlite-with-encryption-password-protection/5877130#5877130

      You must encrypt the database or else any tool will just open it.
      https://forum.qt.io/topic/37817/using-sqlcipher-in-place-of-sqlite
      or alternatively
      http://www.qtcentre.org/threads/35148-Building-QSQLITE-driver-with-AES-256

      1 Reply Last reply
      3

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved