HTML5 Web SQL database file location in chrome
I want to use HTML Web SQL for my next web application project, so I quickly went through the tutorial and wrote the following code:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Web SQL Test</title>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
var db = openDatabase('mydb', '1.0', 'Test DB', 2 * 1024 * 1024);
db.transaction(function (tx) {
tx.executeSql('CREATE TABLE IF NOT EXISTS LOGS (id unique, log)');
tx.executeSql('INSERT INTO LOGS (id, log) VALUES (1, "foobar")');
tx.executeSql('INSERT INTO LOGS (id, log) VALUES (2, "logmsg")');
});
db.transaction(function (tx) {
tx.executeSql('SELECT * FROM LOGS', [], function (tx, results) {
var len = results.rows.length, i;
msg = "<p>Found rows: " + len + "</p>";
document.querySelector('#status').innerHTML += msg;
for (i = 0; i < len; i++){
alert(results.rows.item(i).log );
}
}, null);
});
});
</script>
</head>
<body id="status">
</body>
</html>
I ran the code above in chrome via WAMP ( http: //localhost/web_sql.html ) and I see the expected output in the browser:Found rows: 2
Now I am trying to find the sqlite file that was created by this operation on my PC and after searching, everyone points to this specific folder for the db files:
C: \ Users \ USERNAME \ AppData \ Local \ Google \ Chrome \ User Data \ Standard \ Databases
When I go to this place, it is empty.
On the other hand, changes to the database do not seem to be saved. If I refresh the page, it says anyway Found rows: 2
(of course, it should say 4).
Is that why I can't find the file locally on my PC?
Go to your Chrome URL on chrome://version
and check its value. Your sqlite db should be inside it in the "databases" folder.
And your specific problem with 2 rows found (not 4) is probably caused by inserting rows with the same ids. id is unique, so extra inserts don't work.
Open chrome. Press F12 and then go to the app on the first line (you can use the -> symbol). Go to repository-> websql and see your database :)