How to use the react-native-sqlite-storage.openDatabase function in react-native-sqlite-storage

To help you get started, we’ve selected a few react-native-sqlite-storage examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github blefebvre / react-native-sqlite-demo / src / database / Database.ts View on Github external
public open(): Promise {
    SQLite.DEBUG(true);
    SQLite.enablePromise(true);
    let databaseInstance: SQLite.SQLiteDatabase;

    return SQLite.openDatabase({
      name: DATABASE.FILE_NAME,
      location: "default"
    })
      .then(db => {
        databaseInstance = db;
        console.log("[db] Database open!");

        // Perform any database initialization or updates, if needed
        const databaseInitialization = new DatabaseInitialization();
        return databaseInitialization.updateDatabaseTables(databaseInstance);
      })
      .then(() => {
        this.database = databaseInstance;
        return databaseInstance;
      });
  }
github cqm1994617 / react-native-myCalendar / pages / main.js View on Github external
Image
} from 'react-native';

import chineseLunar from "./chinese-lunar";
import SQLite from "react-native-sqlite-storage";
import newAct from "./newAct";
import actView from "./actView"
let {height, width} = Dimensions.get('window');

function openCB() {
    console.log('open!')
}
function errorCB(err) {
    console.log(err)
}
var db = SQLite.openDatabase({name: "mydata.db", createFromLocation: 1}, openCB, errorCB);
db.transaction((tx) => {
    tx.executeSql('select * from data', [], (tx, result)=> {

    })
});

export default class Main extends React.Component {
    static propTypes = {
        date: React.PropTypes.instanceOf(Date)
    };

    constructor(props) {
        super(props);
        this.state = {
            year: this.props.date.getFullYear(),
            month: this.props.date.getMonth(),
github AbelTesfaye / dingo / src / BL / Database / database.js View on Github external
static open() {
		this.databaseName = 'sqlite.db';

		SQLite.enablePromise(true);

		return SQLite.openDatabase({ name: this.databaseName, createFromLocation: '~sqlite.db' }).then(db => {
			console.log('[db] Database open!');
			this.database = db;
			return db;
		});
	}
github SystangoTechnologies / Crashalert / lib / SQLiteManager.js View on Github external
addCrashReport(crashReport) {

  console.log('Opening database ... 1');
  instance.db = SQLite.openDatabase(database_name, database_version, database_displayname, database_size, that.openCB, that.errorCB);

  instance.db.transaction((tx) => {
    var sql = "INSERT INTO Crash_report (u_d_c_id, error_msg, error_stacktrace) VALUES (?,?,?);";
    tx.executeSql(sql, [instance.deviceID, crashReport.errorMsg, crashReport.errorStack], (tx,results) => {
    });
  });
}
github abdurrahmanekr / Websql-Sqlite-Service / react-native / SqlService.js View on Github external
async execute(sql, value, type) {
		type = type || "array";
		let db = SQLite.openDatabase("react.db", "1.0", "React Database", 200000);
		const tx = await (
					new Promise(resolve =>
							db.transaction(resolve)
					)
			);
		return await (
			new Promise((resolve, reject) => {
				switch (type) {
					case "array":
						tx.executeSql(sql, value, (tx, res) => {
							let list = [];
							res = res;
							for (var i = 0; i < res.rows.length; i++)
								list.push(res.rows.item(i));
							resolve(list);
						});
github sqlite-sync / SQLite-sync.com / amplisync-clients / React Native / amplisync-React-Native / pages / ViewAllUser.js View on Github external
/*Screen to view all the user*/
import React from 'react';
import { FlatList, Text, View } from 'react-native';
import { openDatabase } from 'react-native-sqlite-storage';
import Mybutton from './components/Mybutton';

var db = openDatabase({ name: 'amplisync.db' });
 
export default class ViewAllUser extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      FlatListItems: [],
    };
  }
  ListViewItemSeparator = () => {
    return (
github realm / realm-js / examples / ReactNativeBenchmarks / benchmarks.js View on Github external
async setup(testName) {
        if (testName == "insertions" || testName == "binsertions") {
            try {
                await SQLite.deleteDatabase('test.db');
            } catch (e) {}
        }
        this.db = await SQLite.openDatabase("test.db", "1.0", "Test Database", 200000);

        await this.db.transaction((tx) => {
            tx.executeSql('CREATE TABLE IF NOT EXISTS t1 (string VARCHAR(100), int INTEGER, double REAL, date INTEGER);');
        });

        await super.setup(testName);
    }
github uport-project / uport-mobile / lib / graphql / db-rn-sqlite3.ts View on Github external
return new Promise((resolve, reject) => {
      const db = openDatabase(
        { name: 'test', location: 'default' },
        () => {
          setDb(db)
          resolve()
        },
        reject,
      )
    })
  }

react-native-sqlite-storage

SQLite3 bindings for React Native (Android & iOS)

MIT
Latest version published 3 years ago

Package Health Score

58 / 100
Full package analysis