PDA

View Full Version : qt5.4 commercial setDatabaseName() qsqlite odd error - maximum length for name?



RolandHughes
5th October 2016, 01:01
Version 5.4 commercial on Linux

Weird problem with setDatabaseName() is there a maximum length for local file name?

If I try to setDatabaseName() to /media/mmcblk1p1/.config/Somebody Corp/history.db the open fails with the ubiquitous "out of memory Error opening database"
If I use /.config/Somebody Corp/history.db everything works.

Yes, both directories exist. In fact there are other non QSqlDatabase things in the same method writing to the same /media path successfully. It is just the database which has issue trying to open a file there. Since a space in the path name works with the shorter name I would tend to rule it out as being the problem.

Does anybody know if there is a max length for a local path name or if QSqlDatabase using QSQLITE has a problem with /media/mmcblk type paths? We need to put our history database on the card due to storage limitations on the target. Before I change this around completely to thump in a link after verifying the directory exists I would like to hear from someone else who has been down this path.

jefftee
5th October 2016, 01:37
Hi, I would imagine that the max length is a limit of the OS, not Qt. I can confirm, however, that I have used paths longer than the one you listed above, so I doubt your issue is related to a max length coming into play. Since both of the paths you list above start with a '/' then both start at the root file system. Do you really have a "/.config" directory off of your root file system?

Please post the code you're using using the
tags.

RolandHughes
5th October 2016, 03:32
We certainly have such a directory now, but it could have been a side effect of where I changed the string assignment.

Cannot really post the code as this is an embedded product, but the problem is definitely with the /media/mmc path thing. I had thought about cheating and using a QDir to change the working directory to where the file needed to be, but, this is at startup and with the other threads, I do not know what that would do to things. Certainly backing the string up to /media/mmcblk1p1/.config/history.db didn't help as I tried that. There is just some oddity with that path. In the morning I may experiment starting with /media/history.db and see if that works, then tunnel down to find out where it dies. Need to get it to successfully write to that card though. We write other files there without issue so it is not a hardware or OS problem. It is only opening/creating an SQLite database out there which has trouble.

I guess the next step would be to try and create an sqlite database in the correct location from the command line. That would move the problem outside of Qt to something in the yocto build.