SQLite exisisting database

Please provide the following:

  1. SDK Version: 33.0.7
  2. Platforms(Android/iOS/web/all): all

I’m trying to open a database that i create with my table and my data inside but i cant make it work. I need help. I use this, but is not worlking.

     Expo.FileSystem.downloadAsync(
        Expo.Asset.fromModule(require('../assets/db/AppGYM.db')).uri,
        `${Expo.FileSystem.documentDirectory}SQLite/AppGYM.db`
    );
   
    let db = SQLite.openDatabase('AppGYM.db');
    db.transaction(function (tx) {
        tx.executeSql('SELECT * FROM `Ejercicios`', [], function (tx, res) {
            for (let i = 0; i < res.rows.length; ++i) {
                console.log('item:', res.rows.item(i));
            }
        });
    });

Instead of res.rows.item(i), does this work?

res.rows._array[i]

@wodin The problem is that is not using the database that i already create. Its creating a new one and i dont know why is not working

import { Component } from 'react';

import {Asset} from 'expo-asset'

import { SQLite } from "expo-sqlite";

import DocumentPicker from 'expo-document-picker';

import * as FileSystem from 'expo-file-system';


 FileSystem.downloadAsync(
        Asset.fromModule(require('../assets/db/AppGYM.db')).uri,
        `${FileSystem.documentDirectory}SQLite/appgym.db`
    );
    let db = SQLite.openDatabase(('AppGYM.db'));

    db.transaction(      
        tx => {
            tx.executeSql('SELECT * FROM `Ejercicios`', [], function (tx, res) {
                for (let i = 0; i < res.rows.length; ++i) {
                    console.log('item:', res.rows._array[i]);
                }
            });
        },
        error => {
            console.log("Error")
        },
        () => {
            console.log("Correcto")
        }
    );

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.