• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript better-sqlite3.prepare函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中better-sqlite3.prepare函数的典型用法代码示例。如果您正苦于以下问题:TypeScript prepare函数的具体用法?TypeScript prepare怎么用?TypeScript prepare使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了prepare函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: save

 // data could, e.g., be a uuencoded image
 // We return the sha1 hash of it, and store it, along with a reference count.
 // ipynb = (optional) text that is also stored and will be
 //         returned when get_ipynb is called
 //         This is used for some iframe support code.
 save(data, type, ipynb?): string {
   if (BASE64_TYPES.includes(type)) {
     data = Buffer.from(data, "base64");
   } else {
     data = Buffer.from(data);
   }
   const sha1: string = misc_node.sha1(data);
   const row = this._db.prepare("SELECT * FROM blobs where sha1=?").get(sha1);
   if (row == null) {
     this._db
       .prepare("INSERT INTO blobs VALUES(?, ?, ?, ?, ?)")
       .run([sha1, data, type, ipynb, new Date().valueOf()]);
   } else {
     this._db
       .prepare("UPDATE blobs SET time=? WHERE sha1=?")
       .run([new Date().valueOf(), sha1]);
   }
   return sha1;
 }
开发者ID:DrXyzzy,项目名称:smc,代码行数:24,代码来源:jupyter-blobs-sqlite.ts


示例2: _clean

 _clean(): void {
   // Delete anything old...
   // The main point of this blob store being in the db is to ensure that when the
   // project restarts, then user saves an ipynb,
   // that they do not loose any work.  So a few weeks should be way more than enough.
   // Note that TimeTravel may rely on these old blobs, so images in TimeTravel may
   // stop working after this long.  That's a tradeoff.
   this._db
     .prepare("DELETE FROM blobs WHERE time <= ?")
     .run(months_ago(1) - 0);
 }
开发者ID:DrXyzzy,项目名称:smc,代码行数:11,代码来源:jupyter-blobs-sqlite.ts


示例3: function

exports.loadHist = function(from, to, stock_name, category){
  var db = new Database('afina.db');
  var sqlLoadHist = 'select * from trade_history t';
  var params:string[] = [];
  if(arguments.length >0){
    sqlLoadHist += ' where t.trade_date >= date(?) and t.trade_date <= date(?) and t.stock_name like ? || "%" and t.in_out like ? || "%"';
    params = [from, to, stock_name, category];
  }
  sqlLoadHist += ' order by 1, 2, 3'

  return db.prepare(sqlLoadHist).all(params);
}
开发者ID:lurenja,项目名称:wab,代码行数:12,代码来源:dao.ts


示例4: _init

 _init(): void {
   if (JUPYTER_BLOBS_DB_FILE == "memory") {
     this._db = new Database(".db", { memory: true });
   } else {
     this._db = new Database(JUPYTER_BLOBS_DB_FILE);
   }
   this._db
     .prepare(
       "CREATE TABLE IF NOT EXISTS blobs (sha1 TEXT, data BLOB, type TEXT, ipynb TEXT, time INTEGER)"
     )
     .run();
   this._clean(); // do this once on start
 }
开发者ID:DrXyzzy,项目名称:smc,代码行数:13,代码来源:jupyter-blobs-sqlite.ts


示例5: get_ipynb

 get_ipynb(sha1: string): any {
   const row = this._db
     .prepare("SELECT ipynb, type, data FROM blobs where sha1=?")
     .get(sha1);
   if (row == null) {
     return;
   }
   if (row.ipynb != null) {
     return row.ipynb;
   }
   if (BASE64_TYPES.includes(row.type)) {
     return row.data.toString("base64");
   } else {
     return row.data.toString();
   }
 }
开发者ID:DrXyzzy,项目名称:smc,代码行数:16,代码来源:jupyter-blobs-sqlite.ts


示例6: delete_all_blobs

 // used in testing
 delete_all_blobs(): void {
   this._db.prepare("DELETE FROM blobs").run();
 }
开发者ID:DrXyzzy,项目名称:smc,代码行数:4,代码来源:jupyter-blobs-sqlite.ts


示例7: keys

 keys(): string[] {
   return this._db
     .prepare("SELECT sha1 FROM blobs")
     .all()
     .map(x => x.sha1);
 }
开发者ID:DrXyzzy,项目名称:smc,代码行数:6,代码来源:jupyter-blobs-sqlite.ts


示例8: free

  /*
  free(sha1: string): void {
    // instead, stuff gets freed 1 month after last save.
  }
  */

  // Return data with given sha1, or undefined if no such data.
  get(sha1: string): undefined | Buffer {
    const x = this._db.prepare("SELECT data FROM blobs where sha1=?").get(sha1);
    if (x != null) {
      return x.data;
    }
  }
开发者ID:DrXyzzy,项目名称:smc,代码行数:13,代码来源:jupyter-blobs-sqlite.ts



注:本文中的better-sqlite3.prepare函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript big-integer.isInstance函数代码示例发布时间:2022-05-25
下一篇:
TypeScript better-assert.default函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap