1

I'm new to objective c. I'm trying to create database for first time in my mac i did following steps

******100$ sqlite3 test.sql
SQLite version 3.7.5
Enter ".help" for instructions
Enter SQL statements terminated with a ";"

But wen i enter .schema I'm getting following error

sqlite> .schema
Error: unable to open database "test.sql": unable to open database file

And same error if i go to create a teble

2
  • I am beginning to suspect that you have a text file called test.sql and you are attempting to open it as a database using the sqlite3 command line tool... Commented Aug 10, 2012 at 9:59
  • ya i got it thanx a lot trojanfoe Commented Aug 10, 2012 at 10:48

3 Answers 3

0

You can use Firefox addon SQLite Manager to create database.

Sign up to request clarification or add additional context in comments.

Comments

0

Try something like this:

$ sqlite3 test.sql
SQLite version 3.6.20
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> CREATE TABLE test (a_int INTEGER, a_real REAL, a_text TEXT);
sqlite> .schema
CREATE TABLE test (a_int INTEGER, a_real REAL, a_text TEXT);
sqlite> INSERT INTO test (a_int, a_real, a_text) VALUES (1, 1.24, 'hello world');
sqlite> SELECT * from test;
1|1.24|hello world
sqlite> 

(this was from Linux, but it should be the same...)

BTW the file extension .sql is wrong; that is used for a file containing SQL statements. Use .db instead.

3 Comments

thanks trojanfoe but the error is same even after trying what you've given above
@MudduPatil Are you working in a directory that you have write access?
@MudduPatil And the test.sql file doesn't exist? (as I said in my answer, .sql is used for a different thing than a database file).
0

Check this link for Create database, create table insert into table .

Creating an SQLite3 database file through Objective-C

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.