Skip to content

Instantly share code, notes, and snippets.

@yyssjj33
Created July 10, 2017 20:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yyssjj33/e0a523d7e0d56332bf93d653db356c70 to your computer and use it in GitHub Desktop.
Save yyssjj33/e0a523d7e0d56332bf93d653db356c70 to your computer and use it in GitHub Desktop.
demo for web sql
var order = {
orderId: 100314, format_city: "New York, NY, USA",
lat: 40.7127837, lng: -74.0059413,
price: 150, createTime: "2017-06-08"
};
const db = window.openDatabase("order_test", "1.0", "order map data", 2*1024*1024)
db.transaction(function(tx){
tx.executeSql( "create table if not exists order_data(order_id primary key, format_city, lat, lng, price, create_time)", [], null,
function(tx, err){
throw(`execute sql failed: ${err.code} ${err.message}`);
});
tx.executeSql(`insert into order_data values(${order.orderId}, '${order.format_city}',
${order.lat}, ${order.lng}, ${order.price}, '${date}')`);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment