How to Open or Select Database in SQLite3

Posted on

Introduction

In this article, the focus is about how to open or to select a database. The process for opening or selecting a database is in an SQLite3 database running in Microsoft Windows 10. Actually, before doing that, make sure that there is an SQLite3 database program, tool or command available in the Microsoft Windows 10. For a reference, just check the article wit the title of ‘How to Install SQLite3 in Microsoft Windows’ in this link. Another one is also exist in this link with the title of ‘How to Install SQLite in Ubuntu Linux using Command Line’. So, in order to do that, just try to execute the SQLite3 program, tool or command. The following is the command for doing that :

Microsoft Windows [Version 10.0.18363.628]
(c) 2019 Microsoft Corporation. All rights reserved.

C:\Users\Personal>sqlite3
SQLite version 3.37.0 2021-11-27 14:13:22
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite>

It means the program, tool or command is available and the execution is finally working. So, just proceed directly to open or to select the database.

Open or Select Database SQLite3

In order to open or select database in an SQLite3 database, just perform the following step :

  1. Just execute the program or the command ‘sqlite3’ as follows :

    Microsoft Windows [Version 10.0.18363.628]
    (c) 2019 Microsoft Corporation. All rights reserved.
    
    C:\Users\Personal>sqlite3
    SQLite version 3.37.0 2021-11-27 14:13:22
    Enter ".help" for usage hints.
    Connected to a transient in-memory database.
    Use ".open FILENAME" to reopen on a persistent database.
    sqlite>
  2. Open the database or select the database by typing the following command pattern :

    .open sqlite3_file_path

    For an example, the following is the execution of the command. It is using to select or to open the default Django database file with the name of ‘db.sqlite3’ :

    sqlite> .open 'C:\django\project\db.sqlite3'
    sqlite>
    
  3. In order to prove that the database open or the database select command is working, just type the following command to list the available tables :
    sqlite> .tables
    auth_group base_room
    auth_group_permissions base_topic
    auth_permission django_admin_log
    auth_user django_content_type
    auth_user_groups django_migrations
    auth_user_user_permissions django_session
    base_message
    sqlite>

Leave a Reply