Opening up database and saving the queries - sqlite

I would need to return a homework.
In the homework i should open up an existing database: hw2tennis.db with sqlite3 and do some basic queries and then return it as .sql file. (I assume that .sql -datafile is the same as .db that I have used to put to the end of every database)
At the moment I know how I can open up a database in sqlite3 and I know how to do basic queries. To my understanding SQLite automatically writes on disk the changes so I don't need to save or anything when I do changes to tables and so on.
But I was wondering, is there a way to save the file in a way, that when someone opens it up, they will see the Queries I have made to it.
For example, if task 1 is:
Print all players and their information
So basically, I would write to SQlite: SELECT * FROM Player;
But, when I open up the hw2tennis.db again, there is only the tables and not the queries which is of course logical.
So can I save the FILE in a way that the teacher can see the queries made?
Thanks!

Just answered to your another question at opening up a database
You can save your queries and outputs in a directory of your Windows system (per your screenshot) and send them with the SQLite DB file to your teachers
There're some nice and free GUI tools that you can use:
DB Browser for SQLite at https://sqlitebrowser.org/
SQLiteStudio at https://sqlitestudio.pl/
DBeaver at https://dbeaver.io/ (support multiple platforms)
...etc.

Related

How to save a sqlite database when using Datagrip from Jetbrains

Something I can't get my head around. When I use Sqlite in the console I can do .save test.sqlite.
But how can I save my database to a file when I am inside the Jetbrains datagrip console?
I tried this:
But is does not work. When I search for this on the internet I find how to export data in general within datagrip, but that is not where I'm looking for.
I hope there is some way to to this. Datagrip is handy if it comes to geopackages, for only if I could save them.
sqlite-jdbc has two additional statements: backup & restore, see
their docs. So it does exactly the same as .save
But I'm not sure you need it. When you call .save in command line client, it just copies current database to specified location.
In DataGrip you usually open existing database and work with that. All changes will be reflected in opened file (taking transactions & Co into account). So no reason to "save" your work.

Corona SDK - SQLLite Local Database and Updating

I was just looking for some guidance with my app design. I'm going to have a local sqllite database pre populated with about 1000 records.
These records will need to be read frequently within the app to update the UI.
The records will need to be updated from within the app.
Is a local mysql database the best way to do this or should I be storing all this info in a massive lua table? The database has 2 tables one with 2 columns and one with 10 columns.
I don't want the data to be accessible from outside the app as some of the data is going to be paid for content.
How would I go about releasing updates in the future? If I upgrade my app to version 2 and add new records to the database... how would I go about keeping the users existing data in the database and just adding the updated stuff?
Hope someone can point me in the right direction!
Many Thanks,
Krivvenz.
I think this is fairly simple question. If you need to use data after closing and opening the app you will need sqlite. If the data is created and lost after the app usage, then a table will do. However, the sqlite has also the advantage of querying, deleting and so many other functions without loops etc that you may need to do in tables manually.
You can also append further data during app update. The Sqlite file you create is saved to document directory. That is not deleted if you only update. Simply write a code in your update that reads the existing database and appends the new data. Or create a new file for sqlite and use the old one as backup.

sqlite - How does the command tool command .dump affect connected applications?

I'd like to know how the .dump command affects other applications connected to the same database. I'd like to know this for the following journal modes:
DELETE (the default mode)
WAL (write-ahead-logging)
From reading other posts on this forum .backup uses the online backup API of SQLite. It would be great to have this confirmed as well.
Thanks in advance!
The .dump command reads the contents of the database normally, just as if you would do a bunch of SELECT queries inside a transaction.
This means that when not using WAL, other connections cannot write as long as the dump is running.

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;

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

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.

Resources