storesafe / cordova-sqlite-storage

A Cordova/PhoneGap plugin to open and use sqlite databases on Android, iOS and Windows with HTML5/Web SQL API
Other
2.15k stars 715 forks source link

Open existing sqlite database. #778

Open fkomaralp opened 6 years ago

fkomaralp commented 6 years ago

Hi, I have a question. I have already a sqlite.db on my project, I dont need to create another one. But every project samples using the create method for the open database. How can I open a database with what method.

SQLite method's is; create createDatabase echoTest selfTest

Where is the open method?

brodycj commented 6 years ago

This plugin exports openDatabase, deleteDatabase, echoTest, and selfTest methods. The openDatabase method opens a database with the given file name if it already exists, creates the database only if it does NOT exist.

I think the confusion comes from Ionic Native SQLite which exports a "create" method that opens or creates a SQLite db file (https://ionicframework.com/docs/native/sqlite/).

I will document this as a pitfall when I get a chance. Please file an issue or pull request on https://github.com/ionic-team/ionic-native if you want them to clear it up.