Create database in WebSQL

帅比萌擦擦* 提交于 2019-12-13 01:09:08

问题


Been at this for hours and hours without end debugging why my CREATE TABLE statement failed. Tested it within a MySQL database and it works just fine. But for some reason all my SELECT's can't get my login table like it doesn't exists(The error says).

Here is my SQL for creating the table.

CREATE TABLE IF NOT EXISTS login(
id SMALLINT NOT NULL PRIMARY KEY AUTO_INCREMENT, 
user_type SMALLINT NOT NULL, 
user_data text NOT NULL, 
created_on datetime NOT NULL DEFAULT "0000-00-00 00:00:00"
);

I just cannot see where the error is. One other major issue is that after hours while googling i haven't found any solid wiki that provides enough information about the API for me to really use it. So i had to jump around from site to site to get bites of information.

Hope someone can help me sort out the issue with the Query.


回答1:


I am sry for posting the issue. Already found what i done wrong. Here is the solution for anyone else who might encounter the same thing.

I simply wrote "AUTO_INCREMENT" as in MySQL where i had to be "AUTOINCREMENT" without the _




回答2:


Just as a friendly note, the WebSQL Standard isn't recommended: Is it recommended to use the web sql database for storage on the client side

For a different Client-Side Relational Database Solution, try: SequelSphere

It is an HTML5 Relational Database Engine that supports SQL and stores it's data in Local Persistence. It does not use WebSQL databases, but rather is its own SQL engine. As such, it will work in any JavaScript compliant browser. While it currently only supports Local Storage, very soon SequelSphere will support other local persistence engines such as IndexedDB and File API.

For full disclosure: I am related to the company SequelSphere. :)



来源:https://stackoverflow.com/questions/13250923/create-database-in-websql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!