Module: SQLite3

Defined in:
lib/sqlite3.rb,
lib/sqlite3/value.rb,
lib/sqlite3/errors.rb,
lib/sqlite3/pragmas.rb,
lib/sqlite3/version.rb,
lib/sqlite3/database.rb,
lib/sqlite3/constants.rb,
lib/sqlite3/resultset.rb,
lib/sqlite3/statement.rb,
lib/sqlite3/fork_safety.rb,
lib/sqlite3/version_info.rb,
ext/sqlite3/backup.c,
ext/sqlite3/sqlite3.c,
ext/sqlite3/database.c

Defined Under Namespace

Modules: Constants, ForkSafety, Pragmas Classes: AbortException, AuthorizationException, Backup, Blob, BusyException, CantOpenException, ConstraintException, CorruptException, Database, EmptyException, Exception, FormatException, FullException, HashResultSet, IOException, InternalException, InterruptException, LockedException, MemoryException, MismatchException, MisuseException, NotADatabaseException, NotFoundException, PermissionException, ProtocolException, RangeException, ReadOnlyException, ResultSet, SQLException, SchemaChangedException, Statement, TooBigException, UnsupportedException, Value

Constant Summary collapse

VERSION =

(String) the version of the sqlite3 gem, e.g. “2.1.1”

"2.3.0"
VERSION_INFO =

a hash of descriptive metadata about the current version of the sqlite3 gem

{
  ruby: RUBY_DESCRIPTION,
  gem: {
    version: SQLite3::VERSION
  },
  sqlite: {
    compiled: SQLite3::SQLITE_VERSION,
    loaded: SQLite3::SQLITE_LOADED_VERSION,
    packaged: SQLite3::SQLITE_PACKAGED_LIBRARIES,
    precompiled: SQLite3::SQLITE_PRECOMPILED_LIBRARIES,
    sqlcipher: SQLite3.sqlcipher?,
    threadsafe: SQLite3.threadsafe?
  }
}
SQLITE_VERSION =

(String) The version of the sqlite3 library compiled with (e.g., “3.46.1”)

rb_str_new2(SQLITE_VERSION)
SQLITE_VERSION_NUMBER =

(Integer) The version of the sqlite3 library compiled with (e.g., 346001)

INT2FIX(SQLITE_VERSION_NUMBER)
SQLITE_LOADED_VERSION =

(String) The version of the sqlite3 library loaded at runtime (e.g., “3.46.1”)

rb_str_new2(sqlite3_libversion())
SQLITE_PACKAGED_LIBRARIES =
Qfalse
SQLITE_PRECOMPILED_LIBRARIES =
Qfalse

Class Method Summary collapse

Class Method Details

.libversionObject



63
64
65
66
67
# File 'ext/sqlite3/sqlite3.c', line 63

static VALUE
libversion(VALUE UNUSED(klass))
{
    return INT2NUM(sqlite3_libversion_number());
}

.sqlcipher?Boolean

Returns:

  • (Boolean)


69
70
71
72
73
74
75
76
77
# File 'ext/sqlite3/sqlite3.c', line 69

static VALUE
using_sqlcipher(VALUE UNUSED(klass))
{
#ifdef USING_SQLCIPHER
    return Qtrue;
#else
    return Qfalse;
#endif
}

.status(parameter) ⇒ Object .status(parameter, reset_flag = false) ⇒ Object

Queries the SQLite3 library for run-time status information. Passing a truthy reset_flag will reset the highwater mark to the current value.

Parameters
  • parameter (Integer, SQLite3::Constants::Status): The status parameter to query.

  • reset_flag (Boolean): Whether to reset the highwater mark. (default is false)

Returns

A Hash containing :current and :highwater keys for integer values.



103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'ext/sqlite3/sqlite3.c', line 103

static VALUE
rb_sqlite3_status(int argc, VALUE *argv, VALUE klass)
{
    VALUE opArg, resetFlagArg;

    rb_scan_args(argc, argv, "11", &opArg, &resetFlagArg);

    int op = NUM2INT(opArg);
    bool resetFlag = RTEST(resetFlagArg);

    int pCurrent = 0;
    int pHighwater = 0;
    sqlite3_status(op, &pCurrent, &pHighwater, resetFlag);

    VALUE hash = rb_hash_new();
    rb_hash_aset(hash, ID2SYM(rb_intern("current")), INT2FIX(pCurrent));
    rb_hash_aset(hash, ID2SYM(rb_intern("highwater")), INT2FIX(pHighwater));

    return hash;
}

.threadsafeObject

Returns the compile time setting of the SQLITE_THREADSAFE flag. See: www.sqlite.org/c3ref/threadsafe.html



82
83
84
85
86
# File 'ext/sqlite3/sqlite3.c', line 82

static VALUE
threadsafe_p(VALUE UNUSED(klass))
{
    return INT2NUM(sqlite3_threadsafe());
}

.threadsafe?Boolean

Was sqlite3 compiled with thread safety on?

Returns:

  • (Boolean)


14
15
16
# File 'lib/sqlite3.rb', line 14

def self.threadsafe?
  threadsafe > 0
end