Code Monkey home page Code Monkey logo

database-programs's Introduction

Database-Programs

Python SQLite Programs using SQLite3

Python SQLite Database Connection

  This section lets you know how to connect to SQLite database in Python using the sqlite3 module.
  Use the following steps to connect to SQLite
  How to Connect to SQLite Database in Python

=> 1.Import sqlite3 module

 import sqlite3 statement imports the sqlite3 module in the program. Using the classes 
 and methods defined in the sqlite3 module we can communicate with the SQLite database.

=> 2.Use the connect() method

  Use the connect() method of the connector class with the database name. To establish a 
  connection to SQLite , you need to pass the database name you want to connect . If you
  specify the database file name that already presents on the disk  , it will connect to 
  it . But if your specified SQLite database file doesn’t  exist , SQLite  creates a new 
  database for you.This method returns the SQLite Connection Object if the connection is 
  successful.

=> 3.Use the execute() method

  The execute() methods run the SQL query and return the result.

=> 4.Extract result using fetchall()

  Use cursor.fetchall() or fetchone() or fetchmany() to read query result.

=> 5.Close cursor and connection objects

  use  cursor.clsoe()  and  connection.clsoe() method  to  close  the cursor  and SQLite
  connections after your work completes

database-programs's People

Contributors

vasu312 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.