The SQLite driver CreateDataset? call opens the sqlite file with sqlite3_open. Then, it writes some metadata, if METADATA is true (hich is the default). In the non-default case, it drops through, the ncalls sqlite3_close, and passes the filename off to Open().
Open() checks for a magic header ("sqlite format 3") at the beginning of the file. if it is not there, then the file is not opened, and NULL is returned.
However, if metadata is no, no data is written the sqlite file; it is left at 0 bytes, and no magic header is written. This is okay, because sqlite can still write to the file (I believe), but the end result is that something like ogr2ogr complains.
I think the right solution to this is not to depend on Open(), at least in the case where metadata is not true; instead, simply return the dataset from CreateDataset? directly. However, I'm not sure, and since I just spent 20 minutes in gdb, I'll let somene slightly more sane take up the question.
The end result of this behavior is that ogr2ogr fails a la:
disciplina:~ crschmidt$ ogr2ogr -f SQLite -dsco METADATA=FALSE bybane.sql bybane2spor.shp
SQLite driver failed to create bybane.sql