Understanding Sqlite Virtual File System

admin | May 25th, 2015 | General

Sqlite is an excellent database engine to store relational data. Many time users wish to use traditional technique to store data i.e. using file system. The file system consists of different directories in which data files are saved. If you wish to grasp information about Sqlite database and its file system then you can get necessary information from this article ‘Sqlite Virtual File System’.

Sqlite is equipped with an advanced functionality VFS (Virtual File System) which describe the interface between the Operating System and Sqlite core. A great percentage of functionality associated with VFS depends on files. Basically, VFS is an object of Sqlite3.

Some Facts about Sqlite Virtual File System

The Virtual File System is a layer provided on the top of the file system. The main purpose of using Virtual File System in Sqlite is to allow a client to access a variety of concrete file system uniformly. Some facts associated with VFS files are listed below:

  • APSW, which is employed in providing a thin layer over Sqlite database, can be inherited from existing VFS
  • Executing ‘Sqlite3_vfs-find(file name)’ returns pointer to VFS whose name is provided in the parenthesis
  • File names in Sqlite database are basically ‘zero terminated UTF – 8’ strings
  • The names are case sensitive and hence, special care should be taken
  • If the file name provided does not exist in the database, NULL pointer is returned
  • One can register new VFS by executing the following code:

‘Sqlite3-vfs-register (new file name)’

  • If ‘makeDflt’ flag is set then the associated VFS becomes default VFS
  • Registry of a single VFS can be done multiple number of times without any injury to the file
  • If two files are registered with the same name or a VFS is registered with a name that is either NULL or empty string then the behavior is undefined

Errors and Exceptions with VFS

For returning error from a routine, exceptions are raised in Sqlite. The generated exception gets translated into Sqlite database error codes. ‘exceptionfor()’ is used for returning a specific error code in Sqlite. If the exceptions are not mapped to error codes, then Sqlite error is returned to Sqlite.

The Sqlite database error codes behave in varying ways on dealing with VFS errors. Sqlite raises VFS errors in a different way. If Sqlite was designed to handle VFS errors in an ordinary way then only one exception can be raised and it would be difficult to understand the exceptions that SQL query wants to put. In order to deal with VFS exceptions ‘VFS.excepthook()’ or ‘VSFFile.excepthook()’ methods are used along with exception value, exception traceback and exception type.

Conclusion

The above discussed Sqlite content gave you the elaborated information about the SQLite Virtual File systems and its component. This information provided is sufficient if we see the theoretical aspect, but also you can elaborate more about the files and its system component by using a Free Sqlite Browser, which will consent you to explore about each and every particulars of SQLite database and its file components.

Disclaimer : – © 2020 Sqlite Viewer is an independent provider of Sqlite products & services. Sqlite Viewer is not in affiliation with any of the third–party organizations unless it is expressed explicitly. Read More...