Sqlite database exception: file is encrypted or is not a database in blackberry? - sqlite

I am working on a firm application in which I need to create a local database on my device.
I create my local database through create statement[ It works well]
Then I use that file and perform insert operation through fire-fox sqlite plugin, I need to insert aprox 2000 rows at a time so I can not use code. I just run insert manually through sqlite plugin in fir-fox.
After that I just use that file in my place of my local database.
When I run select query through my code, It show Exception:java.lang.Exception: Exception: In create or prepare statement in DBnet.rim.device.api.database.DatabaseException: SELECT distinct productline FROM T_Electrical ORDER BY productline: file is encrypted or is not a database

I got the solution of this problem, I was doing a silly mistake by creating a file manually by right click in my RES folder, that is not correct. We need to create the database completely from SQlite plugin, then it will work fine. "Create data base from SQLITE(FIle too) and perform insertion operation from SQLITE, then it will work fine"
This is very rare problem, but i think it might be helpful for someone like me....!:)

You should check to see if there is a version problem between the SQLite used by your Firefox installation and that on the BlackBerry. I think I had the same error when I tried to build a database file with SQLite version 2.
You also shouldn't need to create the database file on the device. To create large tables I use a Ubuntu machine and the sqlite3 command line. Create the file, create the tables, insert the data and build indexes. Then I just copy the file onto the device in the proper directory.

For me it was a simple thing. One password was set to that db. I just used it and prolem got solved.

Related

Delphi TFDTable SqLite problems

I deployed a sample.s3db SqLite to my Delphi android project.
set folder to:
fdconnection1.params.Database := system.ioutils.TPath.Combine( system.ioutils.TPath.GetDocumentsPath, 'sample.s3db');
in FDConnection1BeforeConnect event.
in Project-Deployment, set folder to assets\internal\ for Android
However, when I run the app, apparently it can find the physical file, but it says my tablename "Customers" is not found.
so in the BeforeConnect code, if I add a CREATE TABLE SQL create code if not exists, then everything works well but of course the table is empty (whereas my deployed sample.s3db is not empty) ... which proves the FILE sample.s3db was found and not corrupted, but somehow the Table was not found.
Even tried to change in BeforeConnect
FDConnection1.Params.Values['OpenMode'] := 'ReadWrite';
but it still doesn't work.
Any ideas the table name does not work?
I tried to change table name to all caps, in case Android is case-sensitive but it also does not work.
I recommend deleting your app from the android. This will clear out your data. Otherwise your new sqlite file is not deployed if the file already exists. This could happen for instance if you made an error in the path at one point in time so sqlite just created an empty database.
Your connection string looks correct and so does your destination path. Just to be safe, you may also want to clear out your other values for your connection.
fdConnection1.ConnectionDefName:= '';

sqlite database location node-red

I have a Node-RED flow. It uses a sqlite node. I am using node-red-node-sqlite. My OS is Windows 10.
My sql database is configured just with name "db" :
My question is, where is located the sqlite database file?
I already search in the following places, but didn't found:
C:\Users\user\AppData\Roaming\npm\node_modules\node-red
C:\Users\user\.node-red
Thanks in advance.
Edit
I am also using pm2 with pm2-windows-service to start Node-RED.
If you don't specify a full path to the file in the Database field it will create the file in the current working directory for the process, which will be where you ran either node-red or npm start.
Use full path location with file name.
It should work i guess.
This isn't a valid answer, just a workaround for those who have the same problem.
I could't find my database file. But inside Node-RED everything worked just great. So. this is what I have done as a workaround:
In Node-RED, make some select nodes to get all data from tables
Store the tables values somewhere (in a .txt file or something like that)
Create your database outside Node-RED, somewhere like c:\sqlite\db.db. Check read/write permissions
Create the tables and insert the values stored from old database
In Node-RED, inside "Database", put the complete path of the database. For example, c:\sqlite\db.db
In my case this was easy because I only had two database with less than 10 rows.
Hope this can help others.
Anyway, still waiting for a valid answer :)

Using MagicalRecord to prepopulate a database (swift). -wal journal created, however, data not copied to database

(Forgive me since I am not use to posting here. Will do my best)
I am working on an iOS application that will be using a pre-populated database. In my workspace, I have a project for the iOS app and a separate command line tool project to populate the database. I have dragged the database file from the "/Library/Application Support" folder into my iOS project (without using the "Copy Items If Needed"). So when there is a change in the data or additional data is required, I can just run the command line tool to pre-populate the data. From there I will remove the app from the simulator and do a clean. When I run the app, I would think everything would be ok.
It was driving me crazy for the longest but sometimes, I don't see the changes reflected after I remove the app, clean the project and then run. It seems the only way I can get this to work is, after I run the command line tool to pre-populate the database, I have to open the database file using Base, SQLiteStudio or Firefox's sqlite add-on. Once I do that, it seems to work.
When I look in finder, I do see the files .sqlite, sqlite-shm and sqlite-wal. Before opening the database file, I see that the wal file is the biggest (for now it's 2mb). Once I open the file using Base for example, and then close it, the sqlite file is now 2mb.
When the command line is about to finish, I have tried running PRAGMA statements on the file (vacuum, wal-checkpoint) but those did not work. What am I missing here. I also tried using NSManagedObjectContext.MR_defaultContext.saveToPersistentStoreAndWait
I am using the following code to setup and save.
MagicalRecord.setupCoreDataStackWithAutoMigratingSqliteStoreNamed("callithome.sqlite")
MagicalRecord.saveUsingCurrentThreadContextWithBlockAndWait({(context)->Void in
println("Data saved, I hope")})
MagicalRecord.cleanUp()
Any help would be appreciated
You need to enable the DELETE pragma mode for your sqlite store. This will not create the -wal and -shm files. This will make it easier for you to have a single file for use at your pre-populated data store. You will need to use MagicalRecord 3.0 with some of the extra abilities to add custom options to your stores if you'd like o go that route. However, you can still add a store to a coordinator and have that store configured with the proper pragma option as well. That is, MagicalRecord is not necessary if you use normal Core Data.

Copy table from remote sqlite database?

Is there any way to copy data from one remote sqlite database to another? I have file replication done across two servers; however, some changes are recorded in an sqlite database local to each server. To get my file replication to work correctly, I need to copy the contents of one table and enter them into the table on the opposite system. I understand that sqlite databases are not meant for remote access; but is there any way to do what I need? I suppose I could write the contents of the table to a file, copy that file, then add the contents to the other database. This doesn't seem like the best option though, so I'm looking for another solution.
If you have access to the other database file, you can ATTACH it:
ATTACH '/some/where/else/other.db' AS remote;
INSERT INTO MyTable SELECT * FROM remote.MyTable;

Is there anyway to "add" tables to existing database when using Code First?

I want to add a module build on Code First to a running website, which already has an database. If I set my module to run on separated database, it works fine.
But my friend want to just "add" tables created by my modules to existing database, without adding a new database.
Is there anyway to archive that?
The solution is simple and very easy:
Run the module to create a new, clean database
Use SQL Server to generate sql scripts that create tables of that database. I personally think the metadata table is not needed
Run those scripts against target database
Modify the connection string to point to target database
Now it runs flawless! I'm so happy
Thank you.

Resources