Synopsis on DSN Sqlite

admin | May 30th, 2015 | General

In the last blog we gave the overview on Sqlite compilation Procedure, so this time we thought to elaborate an hidden topic that is Sqlite DSN. The Data Source Name is a data structure comprising information on data source (Sqlite database) in order to provide ODBC (Open Database Connectivity) driver all the needed information to establish a connection to the data source. Its structure is analogous to URL address and comprises;

  • Name of Driver connecting to database
  • Data Source Address
  • Name of Data Source
  • Username Accessing Database
  • Password for validating Users

Sqlite is supported by almost all the ORMs due to its light-weighted embedded structure which only needs you to specify the path to the file comprising the whole database. Although Sqlite provide all the modern security mechanisms, you can connect to the database and access or edit it without any credentials like user-name or password.

PDO_SQLITE DSN

Sqlite DSN PDO is a PHP extension to check PHP’s database connections by creating uniform interface allowing developers to create codes which are portable with all the platforms and databases. Amongst these databases comes; IBM DB2, MYSQL, ODBC, PGSQL, and also Sqlite.

PDO_SQLITE DSN — Connecting to Sqlite databases

Description:

The PDO_SQLITE DSN (Data Source Name) comprises following elements:

Sqlite DSN prefix (Sqlite 3)

DSN prefix is sqlite:

  • To access a database on disk, append the absolute path to the DSN prefix.
  • To create a database in memory, append :memory:to the DSN prefix.

DSN prefix (Sqlite 2)

The Sqlite extension in PHP 5.1 provides a PDO driver which supports creation and access of Sqlite 2 databases. You will be able to access databases which you have created with Sqlite extension in PHP previous versions.

The DSN prefix for connecting to Sqlite 2 databases is sqlite2:

  • To access a Sqlite database on disk, append the absolute path to the DSN prefix.
  • To create a database in memory, append :memory:to the DSN prefix.

Examples:

PDO_Sqlite DSN Example for connecting to Sqlite databases:

sqlite:/opt/databases/mydb.sq3

sqlite::memory:

sqlite2:/opt/databases/mydb.sq2

sqlite2::memory:

How to Create User DSN to export the Sqlite Database

dsn-export-for-sqlite-database

Conclusion: – The above discussed section gave a brief about Sqlite DSN and how to create DSN for exporting the database when using a software for Sqlite Corruption Recovery, which will allow you to save your recovered Database in .mdf, .mdb and .sqlite using DSN registry.

Disclaimer : – © 2020 Sqlite Viewer is an independent provider of Sqlite products & services. Sqlite Viewer is not in affiliation with any of the third–party organizations unless it is expressed explicitly. Read More...