swoolcock/monkeysqlite

语言: C++

git: https://github.com/swoolcock/monkeysqlite

用于Monkey-X语言的SQLite3绑定
SQLite3 bindings for the Monkey-X language
README.md (中文)

MonkeySQLite

用于Monkey-X编程语言的SQLite3绑定。 http://www.monkey-x.com/

创建表,插入一些行并运行查询的简单示例:

Import sqlite

Function Main()
    Local db := New SQLite3Database("foo.db")
    db.Exec("CREATE TABLE Test (Foo NUMBER)")
    db.Exec("INSERT INTO Test (Foo) VALUES (100)")
    db.Exec("INSERT INTO Test (Foo) VALUES (200)")
    db.Exec("INSERT INTO Test (Foo) VALUES (300)")
    db.Exec("INSERT INTO Test (Foo) VALUES (400)")
    Local stmt := db.Prepare("SELECT Foo FROM Test WHERE Foo < ?")
    stmt.BindInt(1, 250)
    While stmt.NextRow() <> SQLITE_DONE
        Print "Foo="+stmt.GetInt(0)
    End
    stmt.Finalize()
    db.Exec("DROP TABLE Test")
    db.Close()
End

打印:

Foo=100
Foo=200

空的foo.db文件将保留。

本文使用googletrans自动翻译,仅供参考, 原文来自github.com

en_README.md

MonkeySQLite

SQLite3 bindings for the Monkey-X programming language.
http://www.monkey-x.com/

Simple example that creates a table, inserts some rows, and runs a query:

Import sqlite

Function Main()
    Local db := New SQLite3Database("foo.db")
    db.Exec("CREATE TABLE Test (Foo NUMBER)")
    db.Exec("INSERT INTO Test (Foo) VALUES (100)")
    db.Exec("INSERT INTO Test (Foo) VALUES (200)")
    db.Exec("INSERT INTO Test (Foo) VALUES (300)")
    db.Exec("INSERT INTO Test (Foo) VALUES (400)")
    Local stmt := db.Prepare("SELECT Foo FROM Test WHERE Foo < ?")
    stmt.BindInt(1, 250)
    While stmt.NextRow() <> SQLITE_DONE
        Print "Foo="+stmt.GetInt(0)
    End
    stmt.Finalize()
    db.Exec("DROP TABLE Test")
    db.Close()
End

Prints:

Foo=100
Foo=200

Empty foo.db file will remain.