PDA

View Full Version : Accessing SQLite3 db files from different locations



Jeffb
29th April 2010, 07:06
Probably a very silly question but...
I'm on a Leopard OS X Mac.

When I type "sqlite3 test1.db" at the command line it creates test.db in my home directory.
When I open db "test2.db" from within a QT application, it creates test.db in the application build folder.

How do I access test2.db from the command line?
How do I open test1.db from within my QT application?

Cheers
Jeff

Kumosan
29th April 2010, 07:59
Yep, this is a stupid question..... Naaaaa.... There is no such thing as a stupid question. ;)

You can always give a full path, e.g. sqlite3 /home/foo/bar/.config/mysqlite.db
Works on command line as much as parameter to use from within Qt.

Jeffb
1st May 2010, 08:56
I got it working from within QT by using



QString aDBFilePath = QDir::homePath() + "/test.db";


But still couldn't get it working from the terminal/console.
It just doesn't create a database.

Lykurg
1st May 2010, 13:33
have you the permissions for creating a file at that position?

Jeffb
1st May 2010, 14:02
I've sorted it out.
Using:

./aDirectory/test.db

worked fine.
What was getting me is that the database wasn't showing up until I created a table in it.

Thanks
Jeff