I am struggling to create a database using SQLite3 using Windows 7.
SLite3 is currently installed:
C:\Program Files (x86)\Development\
and has sqlite3.def, sqlite3.dll and a sqlite3 (.exe) file.
I have also updated the environment variable of Path to:
C:\Program Files (x86)\Development\
When I double click:
sqlite3.exe
It opens up the command prompt with the address at the top as:
C:\Program Files (x86)\Development\sqlite3.exe
It opens up and is:
"Connected to a transient in-memory database."
(transient in-memory database) is in red text
Looking around this means that it saves to memory and not hard disk but if you specify:
.save testDB
Then all should be good, but not for me. I have tried:
sqlite3 testDB.db
.save testDB
create table tbl1(one varchar(10), two smallint);
But I get the error:
Error: near "sqlite3" syntax error
Any ideas what I'm doing wrong? I have SQLite manager installed too but I assume I can't use that until a database is saved to disk?
Thanks.
Would changing my Path variable to:
C: \Program Files (x86)\Development\
Make any difference i.e. a space between : and the \?
I ran into the same problem and found help here on the official website. Essentially, you can double-click on the sqlite3.exe file. Then use the .open command to get a persistent database. To create your testDB.db database, you can do as follows:
SQLite version 3.8.8.3 2015-02-25 13:29:11
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> .open c:/sqlite/testDB.db
sqlite>
This should create testDB.db in c:/sqlite or some other folder you specify.
You do not need sqlite3.def or sqlite3.dll.
There are two ways if starting the sqlite3 command-line shell, either by double-clicking on the .exe, or by typing sqlite3 and any parameters in the Command Prompt.
Do not try to start sqlite3 from inside itself.
SQLite Manager is able to create a new database.
Using a wrong path would not work.
Reach the path where you want to start with SQLite through command prompt, for e.g. c:\sqlite>. Now when I use ls command I get c:\sqlite>ls
sqlite3.exe
Now to create database type c:\sqlite>sqlite3 database.db It will create a database for you.
Add sqlite3.exe in a folder, for example: C:\sqlite3\sqlite3.exe
Now go to the path where the sqlite3.exe is and run it.
Per the '.help' instructions, type '.save filename'. When reopening, type '.open filename'. This worked for me.
Related
I'm new to altibase hdb. I was installed altibase hdb with the instructions from here:
http://support.altibase.com/manual/en/631b/html/Installation/index.html
after using the links guides I was able to start the server well but I could not create the database via the recommended command:
CREATE DATABASE mydb INITSIZE=10M NOARCHIVELOG CHARACTER SET KSC5601 NATIONAL CHARACTER SET UTF16;
after some manipulation I found out that the datafiles and anchorlog files were exist here:
$ALTIBASE_HOME\Altibase\altibase-HDB-server-6.3.1\logs
$ALTIBASE_HOME\Altibase\altibase-HDB-server-6.3.1\dbs
So I cleaned them and now I can use the command above to create the database. but if I just rename the databasename to forexample mydbb instead of mydb the command does not work and get me the following error:
Invalid Database Name. Check The Properties and retry.
So what's problem with the database name? what's the difference between mydb and mydbb????
Keep in mind that this same issue should occur even if you install ALTIBASE HDB on Linux.
If you are going to change the database name using the "CREATE DATABASE" command, you must also change the DB_NAME property in your $ALTIBASE_HOME/conf/altibase.properties file to match.
Once you do so, the command you specified should work fine.
OrientDB is using console command create DB by the way run console.bat file on "..\orientdb\bin\". However i need create a .bat separate file run like this command:
create database remote:localhost/test <root> <password> local graph
And run that .bat file by PHP
Thank for advance !
Based on the old documentation at https://code.google.com/p/orient/wiki/ImportFromRDBMS it seem that it is possible and is similar to what i want to do as well.
console.bat database.sql
where all your sql commands are in database.sql. The link about includes a sample for porting a full database over but don;t see why it should not work for similar scripts as well.
That said i have not tested this yet.
I have an sqlite database that needs to be altered. I would like to use the sqlite3 command shell which is included on android adt bundle. I am not so familiar using sqlite3. I tried adding the sqlite database inside the adt bundle where the sqlite3 command shell is found and input in command shell the following commands
.databases - no database available
select * from dbname; - Error: no such table:
By the way, the extension of the file is dbname.sqlite
I tried to study on this link: http://www.sqlite.org/sqlite.html but can't seem to make it happen.
SQlite doesn't have the concept of multiple databases, like SQL Server does, for example.
Just run the sqlite3 executable passing the name of the database file.
sqlite3 mydb.sql
I have a ton of postgresql dump files I need to peruse through for data. Do I have to install Postgresql and "recover" each one of them into new databases one by one? Or I'm hoping there's a postgresql client that can simply open them up and I can peek at the data, maybe even run a simple SQL query?
The dump files are all from a Postgresql v9.1.9 server.
Or maybe there's a tool that can easily make a database "connection" to the dump files?
UPDATE: These are not text files. They are binary. They come from Heroku's backup mechanism, this is what Heroku says about how they create their backups:
PG Backups uses the native pg_dump PostgreSQL tool to create its
backup files, making it trivial to export to other PostgreSQL
installations.
This was what I was looking for:
pg_restore db.bin > db.sql
Thanks #andrewtweber
Try opening the files with text editor - the default dump format is plain text.
If the dump is not plain text - try using pg_restore -l your_db_dump.file command. It will list all objects in the database dump (like tables, indexes ...).
Another possible way (may not work, haven't tried it) is to grep through the output of pg_restore your_db_dump.file command. If I understood correctly the manual - the output of pg_restore is just a sequence of SQL queries, that will rebuild the db.
In newer versions you need to specify the -f flag with a filename or '-' for stdout
pg_restore -f - dump_file.bin
I had this same problem and I ended up doing this:
Install Postgresql and PGAdmin3.
Open PGAdmin3 and create a database.
Right click the db and click restore.
Ignore file type.
Select the database dump file from Heroku.
Click Restore.
pg_restore -f - db.bin > db.sql
Dump files are usually text file, if Not compressed, and you can open them with a text editor. Inside you will find all the queries that allow the reconstruction of the database ...
If you use pgAdmin on Windows, can just backup the file as plain text, there is one option when you do backup instead of pg_dump in command line prompt.
I have made changes to my model.py in Django and now I want to syncronize these changes. It's fine to delete the tables and re-create them. However, nothing seems to work. I am using sqlite3:
syncdb: only works first time, not with changes
"python manage.py sql my_site", followed by syncdb: I thought this would 'redo' it all, but the table still only has the old columns (or so I assume as I get an error when I try to access the table using my model).
Then I figure that I can access the database directly and delete the tables that way. However, I don't know how to get "in" to the DB where I can execute commands. Typing sqlite3 from the command prompt is not recognized. I also tried "python manage.py sql my_site", but I again get the message that sqlite3 is not recognized.
Suggestions?
First you have to install the command line tool for sqlite. On Ubuntu/Debian, you can simply do
sudo apt-get install sqlite3
On windows, you can download it from here: http://www.sqlite.org/download.html. Look for the one that looks like sqlite-shell-win32-xxx.zip.
Use it like this:
> sqlite3 /path/to/your/database
;show some help
.help
; list all databases
.databases
; clear the contents of a table
DELETE FROM <tablename>;
See also the command line reference: http://www.sqlite.org/sqlite.html
and the sqlite SQL reference: http://www.sqlite.org/lang.html.
Using the "ALTER TABLE" sql command, you can also add columns without deleting the entire contents of the table. To do this, compare the output of .schema in sqlite3, and the output of manage.py sql my_site to find out which columns you need to add.
An example:
ALTER TABLE "buildreport_series" ADD COLUMN "parameters" text
Use Django's built in database management tool:
python manage.py dbshell
And issue the required sql commands. The sql command will only print to stdout what the required sql is to create the current tables (as defined by the current models).