# Sqlite3/activer record permissions problem (no ror)

**URL:** <https://www.ruby-forum.com/t/sqlite3-activer-record-permissions-problem-no-ror/159594>\
**Category:** Ruby\
**Created:** [February 6, 2009, 4:03am UTC](https://www.ruby-forum.com/t/sqlite3-activer-record-permissions-problem-no-ror/159594 "2009-02-06T04:03:31Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![djames](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/7ab992/32.png) [@djames](https://www.ruby-forum.com/u/djames)\
**Post date:** [February 6, 2009, 4:03am UTC](https://www.ruby-forum.com/t/sqlite3-activer-record-permissions-problem-no-ror/159594/1 "2009-02-06T04:03:31Z")

</div>

I’m using Ruby and ActiveRecord in a web environment (no ror). The  
database is sqlite3. sqlite3-ruby is installed. I can add records to  
the database from Ruby scripts using ActiveRecord just fine provided  
that I am root. However, as any other user it bombs out with the error  
message shown below. If this is going to work for me, I need to have  
the user ‘Apache’ be able to add records to the database. Can anyone  
please tell me what the problem is and how I might fix it. Thanks for  
any input. Here is the relevant part of the error message:

/usr/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active\_record/connection\_adapters/abstract\_adapter.rb:150:in  
`log’: SQLite3::SQLException: SQL logic error or missing database:  
INSERT INTO news

---

<div class="post-metadata">

**Author:** ![djames](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/7ab992/32.png) [@djames](https://www.ruby-forum.com/u/djames)\
**Post date:** [February 6, 2009, 2:04pm UTC](https://www.ruby-forum.com/t/sqlite3-activer-record-permissions-problem-no-ror/159594/2 "2009-02-06T14:04:23Z")

</div>

My guess is that the sqlite database is owned by root (or by anybody  
other  
than the user ‘Apache’) and does not have world write privileges. Look  
at  
the permissions on the database file.

–wpd

---

<div class="post-metadata">

**Author:** ![djames](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/7ab992/32.png) [@djames](https://www.ruby-forum.com/u/djames)\
**Post date:** [February 6, 2009, 6:06pm UTC](https://www.ruby-forum.com/t/sqlite3-activer-record-permissions-problem-no-ror/159594/3 "2009-02-06T18:06:11Z")

</div>

> My guess is that the sqlite database is owned by root (or by anybody  
> other than the user ‘Apache’) and does not have world write privileges.  
> Look at the permissions on the database file.

Unfortunately, the database is owned by ‘apache’ and assigned to the  
group ‘apache’. In addition, at the moment the database has world write  
permissions. I am hopeful that after I get this problem resolved, the  
write permissions can be restricted to a single user, presumably  
‘apache’. Thanks for your input. I should have mentioned those facts  
in my post.

```
    ... doug
```

---

<div class="post-metadata">

**Author:** ![djames](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/7ab992/32.png) [@djames](https://www.ruby-forum.com/u/djames)\
**Post date:** [February 6, 2009, 7:03pm UTC](https://www.ruby-forum.com/t/sqlite3-activer-record-permissions-problem-no-ror/159594/4 "2009-02-06T19:03:14Z")

</div>

FWIW, I just got this working by making the directory that contains the  
database owned by ‘apache’ and and assigned to the ‘apache’ group.  
Thanks for the help.

```
 ... doug
```

---

<div class="post-metadata">

**Author:** ![djames](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/7ab992/32.png) [@djames](https://www.ruby-forum.com/u/djames)\
**Post date:** [February 8, 2009, 8:44am UTC](https://www.ruby-forum.com/t/sqlite3-activer-record-permissions-problem-no-ror/159594/5 "2009-02-08T08:44:21Z")

</div>

On Sat, Feb 07, 2009 at 03:02:31AM +0900, Doug J. wrote:

> FWIW, I just got this working by making the directory that contains the  
> database owned by ‘apache’ and and assigned to the ‘apache’ group.  
> Thanks for the help.
> 
> ```
> ... doug
> 
> ```

That would be because sqlite needs write permissions to the directory so  
it may  
create the .journal file.

enjoy,

-jeremy
