将SQLite SQL文件导入WEB SQL数据库的最简单方法是什么 [英] What's the simplest way to import an SQLite SQL file into a WEB SQL Database

查看:219
本文介绍了将SQLite SQL文件导入WEB SQL数据库的最简单方法是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

也许我遗漏了一些东西,但是我需要一个预先填充了数据负载的客户端数据库.

perhaps I'm missing something, but I need a client side database pre-populated with a load of data.

为了测试客户端数据库是否可以完成任务,我使用transaction.executeSql()方法创建了一些带有伪数据的伪表.但是据我所知,它需要为每个单个CREATE TABLE和INSERT INTO查询执行executeSQL调用.我很懒,这对我来说似乎太多了.

To test whether client side databases were up to the task, I created a few dummy tables with dummy data using the transaction.executeSql() method. But from what I can gather, it requires an executeSQL call for every single CREATE TABLE and INSERT INTO query. I'm lazy, and that seems like too much work to me.

我想知道...:我可以使用SQLite GUI很快创建一个SQLite表.我尝试导出一个SQL文件并在一个executeSQL语句中运行所有文件,但这仅处理第一个"CREATE TABLE"位,而没有插入内容.

I'm wondering...: I can create an SQLite table fairly quickly using an SQLite GUI. I've tried exporting an SQL file and running it all in one executeSQL statement but that just processes the first 'CREATE TABLE' bit none of the inserts.

是否存在一些我不知道的同时运行多个查询的特殊交易对象方法?

Is there some special method of the transaction object that I'm not aware of for running multiple queries at once?

这是供移动Safari购买的方式,

This is for Mobile Safari buy the way, which according to Apple uses an SQLite Database to power their client side database stuff.

推荐答案

我每行用一条命令将所有sql代码放入文件中,然后使用ajax提取文件并遍历执行sql的每一行

i put all the sql code into a file with one command per line then used ajax to pull file and loop over each line executing the sql

提示:使用if(如果不存在),以便您每次都可以调用它来初始化数据库

tip: use the if not exists so you can call it every time to init your database

这篇关于将SQLite SQL文件导入WEB SQL数据库的最简单方法是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆