CakePHP: Database connection "Sqlite" is missing, or could not be created

Just downloaded 2.1.1 stable to read a SQLite database.

There’s a nice diagnostics page to welcome any developer, except it complained about my database config:

Database connection "Sqlite" is missing, or could not be created.

So I thought it might’ve been a missing driver, or something, so I looked in lib/Cake/Model/Datasource/Database:

-rw-rw-r-- 1 kzhiwei kzhiwei 20K 2012-03-25 18:30 Mysql.php
-rw-rw-r-- 1 kzhiwei kzhiwei 25K 2012-03-25 18:30 Postgres.php
-rw-rw-r-- 1 kzhiwei kzhiwei 16K 2012-03-25 18:30 Sqlite.php
-rw-rw-r-- 1 kzhiwei kzhiwei 23K 2012-03-25 18:30 Sqlserver.php

Everything looked fine to me, except that naggy error. It turns out additional stuff is required for PHP to talk to SQLite. If you’re on Oneiric Ocelot (11.10), you’re in luck. The package name is “php5-sqlite”, so you can just use a shell to:

sudo apt-get install php5-sqlite -y
sudo /etc/init.d/apache2 restart

Once that is done, use ‘:memory:’ for the database param, to make sure that the server setup is OK.

Lastly, adjust the filename of the database file; e.g. mine is ‘/app/webroot/trac.db’, so I simply use ‘trac.db’. Once this is done, you may encounter another error:

Database connection "SQLSTATE[HY000] [14] unable to open database file" is missing, or could not be created.

This is due to a permissions problem, so check if the www-data group owns webroot, trac.db. It should like:

drwxr-xr-x 6 kzhiwei www-data 4.0K 2012-04-25 10:46 .
-rw-rw---- 1 kzhiwei www-data 12M 2012-04-24 18:45 trac.db

Advertisements

Synaptic games deinstall for Xubuntu 10.04

Copy the following text for use w/ Synaptic when marking game-related packages for deinstall in Xubuntu 10.04. It may also work with other GNOME2-based, Ubuntu derivatives. The alternate installer does not provide the option to mark/unmark any packages at inastall time, hence the need for this.

aisleriot deinstall
quadrapassel deinstall
gnome-mahjongg deinstall
gnome-games-common deinstall
gnome-sudoku deinstall
gnomine deinstall

Alternatively:

$ sudo apt-get remove aisleriot quadrapassel gnome-mahjongg gnome-games-common gnome-sudoku gnomine -y

OCIEnvNlsCreate() failed

Wanted to work on an Oracle project from home last weekend, but I received this message:

Warning (2): ocilogon() [function.ocilogon]: OCIEnvNlsCreate() failed. There is something wrong with your system – please check that ORACLE_HOME and LD_LIBRARY_PATH are set and point to the right directories [CORE/cake/libs/model/datasources/dbo/dbo_oracle.php, line 171]

A little bit of system background here. I’m using Linux Mint 8, running oracle-xe 10.2.0.1-1.1. oci8 was compiled via pecl, with one notable difference from my previous guide. I did not use instantclient (i.e. instantclient,/usr/lib/oracle/11.1/client/lib), so the phpinfo output for the oci8 section was quite different.

It looked like:

OCI8 Support enabled
Version 1.4.1
Revision $Revision: 293235 $
Active Persistent Connections 0
Active Connections 0
Compile-time ORACLE_HOME /usr/lib/oracle/xe/app/oracle/product/10.2.0/server
Libraries Used -Wl,-rpath,/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/lib -L/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/lib -lclntsh
Temporary Lob support enabled
Collections support enabled

I did some searching. I figured it was something to do with environment variables, as my colleague had helped me to resolve the problem previously. I’d forgotten the fix, so this post will serve as a reminder, if needed.

Now ORACLE_HOME and LD_LIBRARY_PATH were defined via my .bashrc, which consists of just one line:

. /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/oracle_env.sh
echo $ORACLE_HOME
/usr/lib/oracle/xe/app/oracle/product/10.2.0/server
echo $LD_LIBRARY_PATH
/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/lib:

Some people suggested using Apache’s SetEnv — which I tried — but the error did not go away. That same colleague suggested this morning I use the envvars file in Ubuntu instead, which helped to resolve my problem, at least:

Adding these two lines solves my problem:

export ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server
export LD_LIBRARY_PATH=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/lib:

Seriously, my journey with Oracle has always been a rocky one. I wonder why this product is so… inaccessible.

Shell commands for Ubuntu Netbook Edition 9.10

As above, useful when deploying a client PC.

# installing Wine, IEs4Linux
sudo add-apt-repository ppa:ubuntu-wine/ppa
sudo apt-get update
sudo apt-get install wine
wget http://www.tatanka.com.br/ies4linux/downloads/ies4linux-latest.tar.gz
tar zxvf ies4linux-latest.tar.gz
cd ies4linux-*
./ies4linux

# removing games
sudo apt-get remove gnome-games
sudo apt-get autoremove

# clearing command history
history -c

Comparing MEPIS 8 and Ubuntu 9.04

This post has been updated due to new information regarding Ubuntu 9.04.

I first tweeted about Ubutu 9.04 a week ago. Now I know I’m not exactly comparing apples with apples, since MEPIS 8 is based on Debian 5.0 and uses KDE 3.5, whilst Ubuntu 9.04 uses GNOME 2. I might be better off evaluating Kubuntu, the 9.04 release uses KDE 4, which I’d used previously, and disliked due to its (apparent) gradual reduction in speed.

But back to Ubuntu versus MEPIS. Since 10th June, I’ve been using it as a web developer machine on a Compaq nc8230. This machine is better-speced that the IBM R52 I use for MEPIS, so I’m giving Ubuntu the benefit of faster machine here. We’ll see if that pans out in Ubuntu’s favour later on.

Package Management

I develop in PHP, so I use Apache, MySQL and Oracle (remote server) on a daily basis. From my point of view as a developer, all of the .deb packages I use have the same name as in MEPIS. Synaptic, used in both MEPIS and Ubuntu, handles packages very well, so it is a tie here.

MEPIS 1, Ubuntu 1.

Applications

For applications however, I still felt that, overall KDE’s were more suitable for me, even though I was able to find GNOME-based replacements for the applications I used in MEPIS:

  • Kate to Gedit. Kate can syntax highlight my .ctp files, while Gedit has no such configuration option. Kate has sessions so I can quickly switch between projects, Gedit does not.
  • Konsole to Terminal. Konsole remembers my tabs, Terminal does not.
  • Katapult to Do. I prefer the default Alt+Space shortcut for Katapult, Do does it like Win+Space, because Alt+Space is used by GNOME. I also prefer if a calculator is built into Do, so I press Win+Space+32*5 and I get the result (160) onscreen.
  • Kdesvn,Kdiff3 Kompare to Meld. Meld is MUCH better than either of the 3 applications, as I can do 3-way file/directory comparison easily. It can even open a Subversion-ed directory and handle it correctly)
  • No Dropbox client in MEPIS, versus official Dropbox client in Ubuntu. Dropbox works very well, as it is the official release from the Dropbox guys. I’m still waiting (hoping) for a KDE-based one, but maybe they are reluctant to write one in KDE 3.5, then later rewrite for KDE4?

MEPIS 1, Ubuntu 0.5 (due to Meld, Dropbox).

Speed/Stability

I feel that Ubuntu 9.04 has some way to go, as I’d to POWER OFF the laptop as Ubuntu does the dreaded “window goes dark” thing, and I see/hear alot of hard drive activity, and then I have to (painfully) switch to Terminal, and then type killall <process>. Usually, the culprit is Firefox 3.0.11.

Previously I’d written about how unstable 9.04 was. After some reading on the forums, I figured it might be a graphics issue. Setting System -> Preferences -> Appearance -> Visual Effects to “None”, seem to have resolved my stability problems. How strange, yet comforting. Ubuntu is now as stable as MEPIS (or probably most Linux distros, anyways) is.

MEPIS 8, on the IBM R52, meanwhile is fast and stable, albeit with less special effects. I must admit, I was wowed by the special effects, but not at the expense of speed, and particularly stability.

MEPIS 1, Ubuntu 0. MEPIS 1, Ubuntu 1.

Conclusion

I’ve no issues with Synaptic, as it is used to manage packages in both MEPIS and Ubuntu.

I loved to use Dropbox and Meld in Ubuntu, so much that I was probably willing to accept the differences between kate/gedit, konsole/terminal, katapult/do. What was frustrating to me was to develop halfway, and then have to wait for the system to return control of the UI to me, and if not reboot.

The overall score is MEPIS 3, Ubuntu 1.5. This scoreline is obviously subjective, but you’ve heard all the good things about Ubuntu, have a slow(er) laptop, please do consider MEPIS. The overall score is MEPIS 3, Ubuntu 2.5. I still prefer KDE 3’s apps, but it wouldn’t be a huge leap to jump to Ubuntu’s GNOME Desktop, or for users that still prefer KDE, Kubuntu 8.04 (KDE 3.x) or Kubuntu 9.04 (KDE 4.x).

Both MEPIS and Ubuntu support audio/wireless networking flawlessly, unlike (cough, cough) Debian. At this point, I really don’t see the benefits of using Ubuntu (mostly due to its speed/stability issues) over MEPIS, so yeah, I’m a fan.

References

Debian, MEPIS and Ubuntu from en.wikipedia.org