hii readers
readers, This is our introduction part of python shelve module tutorial
series and in this part, We will discuss what is shelve? and what are the usages of python shelve
module?
But First If You Are New Visitor,
Then, Don't Forget To Check Our Index Because their You can find really many interesting stuff.
So, let's start our discussion.
our first question is.
Q 1. What Is Shelve?
Ans. Shelve is a dictionary-like object use for storing python object. this module is very easy to use
because its interface completely works like a python dictionary object. this module is managed by
python anydbm module.
Q 2. The difference between shelve and anydbm module?.
Ans. Shelve Is Completely Based on anydbm python module but the difference is shelve pickle data
for storing and writtind data in database. that's why any python object that can handle by pickle
python module. you can store it in shelve database.
Simple Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | #!/usr/bin/python #
# Importing Modules import shelve
# db_name = Name Of Database. db_name = "example_database_shelve.db"
# Open Database And Create Shelve Object handler. db = shelve.open(db_name)
# # Creating A List Only For Exmaple Purpose # storelist = ["Dog", "cat", "rat", "snake", "kite"] # # Storelist In Database. # db['store_list'] = storelist # # Close Database # db.close()
|
So, stay tunned with us.
For More Update, Visit Our Blog Regularly.
For Any Type of Suggestion, Help Or Question
Contact me:
Suraj
surajsinghbisht054@gmail.com