Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;
});
}
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(),
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;
});
}
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) => {
});
});
}
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);
});
/*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 (
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);
}
return new Promise((resolve, reject) => {
const db = openDatabase(
{ name: 'test', location: 'default' },
() => {
setDb(db)
resolve()
},
reject,
)
})
}