I am using a GIS program called ArcGIS to create a .dbf file from shapefile data. I have tried opening the .dbf file in sqlite3. sqlite3 stated "Error: file is encrypted or is not a database". What is causing this error? Why can't I open the .dbf in sqlite3?
When I open the dbf file in Excel I have no issues.
Edit: I am new user to Stack Overflow. SO I am confused at why there no explaination for -1 Vote. What does it mean? And if I get no input into why down votes happen, how can I learn to write better questions?
Edit 2: Since getting an answer, I have researched more and understand better that dbf files are old format that has no SQL component to it. Originally I thought (wrongly) if dbf and sqlite are both databases then they must be compatible. When just starting out, basic questions to you may not be so basic to others.
A .dbf file is a dBase database file. SQLite is a different database system with a completely different database file format. SQLite clients are not made to handle .dbf files. So the behavior you see is expected.
If you really need to access this data with a SQLite client, you could use ArcGIS's Create SQLite Database tool and copy the data from the shapefile to a SQLite database.
Is it possible to save a mapping file which SSIS can use to decide the data type based on the column names rather than going and updating it in the Advanced section of the 'Flat File Connection Manager Editor'. Thank you
This is a common problem faced by every SSIS developer. Whenever you make changes in a flat file connection, you lose all data type mappings and you have to manually edit this by using the advanced editor.
But you can save your life using the following:
Practice #1
When you work with an existing connection, make sure you have the flat file at the reference location of the flat file connection with the same name. If you forget to save it or don't find it, try the second practice.
Practice #2
Follow the steps below before using the SSIS package:
Open package in XML file format.
Find the flat file connection.
Read the file name and path of flat file connection.
Get the output copy of the final output file (usually you can find where SSIS is exporting final output file).
Copy the final output file and rename with the file connection's file name and paste it to the flat file connection location.
Remove all the data from file except the column list (make sure you keep the file format as it is, e.g., CSV or Excel).
Close the XML of the SSIS package & close the package.
Reopen the SSIS package and you saved your life.
This trick works for me in all my cases.
I've recovered data from a formatted hard drive for use in a lawsuit. The data is Skype logs, which are stored in SQLite3 databases. Unfortunately, the disk was formatted and a new copy of OS X was installed on the drive. I scanned the drive and found the files I am looking for, but it seems that the database I'm after is corrupt.
I tried the following command I found by searching on SO:
$ sqlite3 mydata.db ".dump" | sqlite3 new.db
Unfortunately, dumping this way excludes the table of records I'm looking for (Messages). Since I can get the format of the DB from Skype by just logging in with another account and generating a new main.db for it, do I have any additional options for extracting the contents of the corrupt DB? Failing that, is there a way to export the raw contents of the database in a text file or something? I only care about grabbing certain messages, which I can search for.
When the database is corrupt, the ".dump" command extracts all of the usable information, but then ends with a ROLLBACK because it encountered corruption.
Instead, store the output in a file:
$ sqlite3 mydata.db ".dump" > mydata.dump
Then, you can view the data directly in that file, or you can change the last line from "ROLLBACK" to "COMMIT" using a text editor. After that, you can load the valid portion of the data into a database using:
$ sqlite3 new.db < mydata.dump
First check for the PRAGMA integrity_check in command console and click on play button, note down the errors and repair them seperately or try exporting and then importing SQL file to new database and restart the database, it generally removes the slug files stored in the cache. If the above method does not work out then you can try SQLite database recovery tool https://www.recoveryandmanagement.com/repair-sqlite-database-manually/
I am a newbie to sqlite3.
I have some files which contain a .db file and also another file which contains the definition s of many tables. I try to open with notepad and see that it has create table definitions of many files.
I am trying to read them in sqlite3 in linux.
I try to use .read FILENAME after which I try to see the tables by giving .tables command.
I cant see them.
Is there a way I need to source the file or execute.
Thanks for your help in advance
I haven't done anything with SQLite in a long time, but when I did work with it I used a Firefox extension that made it easy.
Check out SQLite Manager to open the DB file:
https://addons.mozilla.org/en-US/firefox/addon/sqlite-manager/
.read FILENAME already executes the sql script in the FILENAME. Check if your .db file is writable and/or if the sql contained your file is correct.
Where is the SQLite database stored i.e. directory path on windows 7 when created ?
A SQLite database is a regular file. It is created in your script current directory.
.databases
If you run this command inside SQLite
.databases
it lists the path of all currently connected databases. Sample output:
seq name file
--- --------------- ----------------------------------------------------------
0 main /home/me/a.db
There is no "standard place" for a sqlite database. The file's location is specified to the library, and may be in your home directory, in the invoking program's folder, or any other place.
If it helps, sqlite databases are, by convention, named with a .db file extension.
If you are running Rails (its the default db in Rails) check the {RAILS_ROOT}/config/database.yml file and you will see something like:
database: db/development.sqlite3
This means that it will be in the {RAILS_ROOT}/db directory.
When you call sqlite3_open() you specify the filepath the database is opened from/saved to, if it is not an absolute path it is specified relative to your current working directory.
It depends on how you initialized the database. If you used the command line shell for SQLite (e.g. sqlite3 ex1) to create the database, it'll be a path from the root of your local machine. If you used a Python script to create the database, it'll be a path from your project.
To check the former, run the command line shell:
sqlite3
sqlite> .databases
To check the path in your project, you can print the path in the connection. For example:
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
DATABASE = 'db'
def get_db_connection():
print(os.path.join(BASE_DIR, DATABASE, "database.db"))
conn = sqlite3.connect(os.path.join(BASE_DIR, DATABASE, "database.db"))
conn.row_factory = sqlite3.Row
return conn
In my case I think it was an access issue. I saved the SQLite files to "C:/Program Files (x86)/sqlite". I CD'd there, ran sqlite3, and created a database called test.db:
As you can see, I ran .database, which told me the .db file was created in the same directory, so I went to confirm in File Explorer, and it wasn't there:
Curiously the database was working correctly in spite of this.
It was only through trial-and-error that I discovered that I could save in some locations, but not others. It appears to me that SQLite can't save to locations that require elevation. In my case, moving from Program Files to My Documents made the issue go away.
I find it quite irritating that SQLite doesn't just tell me "access denied" instead of trying to be clever and saving to some location that I can't even find.
In Windows machines (Windows 2010), by default, the new SQLite database files will be stored in the same folder where Sqlite3.EXE application is stored in your machine. However , we can create a new folder in Windows and within sqlite> prompt, you may use the .cd to change to the new working directory.
It is a good idea to give a .db file extension to the new database files that you create (even though it is not mandatory to have any file extension)
The SQLite command, .databases will show the default database "main" or currently created or currently opened database or all "attached" database files with file path. The .attach is useful to attach more than one database file to the current connection when we want to work with tables belonging to different databases.
Regards,
Biju Joseph N.,
Houston TX, USA (January 12, 2023)
the database path will be displayed, when using .databases
SQLite is created in your python directory where you installed the python.
SQLit Database is simply a file where your local data is stored on your local machine
In Windows 10 if in the prompt command the path where you start sqlite is
C:\users\USER_NAME
You can find it in the user home folder.
The .db file is stored where you start the sqlite command.
I hope this solve the issue