Here iam going to briefly explain (with sample) on web database API.
Web Database API or Client-side Database is one of the HTML 5 feature.
Modern Browsers are providing client-side database, as of now, opera 10.6 and chrome 4+ (may be safari too) are supporting this feature. IE9, FF4 may support this feature in their final release.
Here iam providing sample html page, to get start with web database API, download the sample at the end of the post.
Most web browsers are likely to implement this embedded database feature using "sqlite". check this site for proper usage or supported SQL statements: www.sqlite.org
In this sample example, iam creating a table called "MyTable" with 3 columns: id, first name, last name.
The UI provides, CreateTable, DropTable, AddRecords, ShowTable buttons and status text and result in Table.
If you have Chrome web browser, check chrome developer tools (storage tab), one can check, query(run SQL) the data for a site.
Below is the screenshot from Chrome.
screenshot from Opera.
For support in older browsers, you need to install GoogleGears plugin.
(most of the features of GoogleGears are now included in HTML5).
Points to note:
- Don't open multiple instances of database connections, it's allowed, but it's better to create one and make it globally accessable.
Download the sample here.