[Development] Issues with a mariadb script and QSqlQuery

Scott Bloom scott at towel42.com
Wed Apr 15 01:22:05 CEST 2026


I am trying to create a database from a mariadb-dump run.

I am storing the file in a qrc file.

the command used to generate the sql file is as follows:

"${MARIADB_PATH}/mariadb-dump" --user=${BACKUP_USER} ${BACKUP_USER_PASSWORD} -h ${HOST} -P ${PORT} --max-allowed-packet=1GB --single-transaction --extended-insert  --flush-logs --flush-privileges --all-tablespaces --hex-blob --dump-date --routines --events --databases ${TEST_DATABASE}  --result-file=$FILE

I have no issues running mariadb < $FILE of the generated sql file.

However, when I try to use QSqlQuery to send the data, it doesn't error out or report any issues in query::lastError however, it only creates a small subset of the tables from the database.

I run the following commands

auto db = QSqlDatabase::addDatabase( "QMARIADB", connName );
db->setHostName( <hostname> );
db->setPort( <port> );
db->setUserName( <username> )
db->setPassword( <password> );
if ( !db->open() )
              error();
auto file = QFile( ":/init.sql" );
if ( !file.open( QFile::ReadOnly ) )
              error();

auto sql = QString::fromUtf8( file.readAll() );
auto query = QSqlQuery( sql, *db );
if ( query.lastError() != QSqlError::NoError ) // no errors reported
      error()

No errors are reported, query.lastError() returns QSqlError::NoError

But the command stops at some of the pragma style comments that are generated.

Any thoughts/ideas?

Scott







-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20260414/b7420a57/attachment.htm>


More information about the Development mailing list