Restoring a SQL Server database backup file (.bak)

Introduction On regular basis we need to restore the database, either will only schema of the database, or many times both data as well as schema.  Most of the applications (either Web application e.g. ASP.NET based apps, or Windows applications e.g. WPF based apps) requires 'reference data' such as drop-down data, types of users, etc. So what is the most optimum, reliable way of moving database either on separate database server, or on the same database server but with different database name? There are several ways to achieve this objective but my personal preference is to first create the database backup file i.e. 'my_backup.bak' using Microsoft SQL Server Management Studio , and then restoring that backup file to create new database.  This article focuses on restoring the backup file to create a new database. How to create the backup file will be covered in another article.   This article addresses below points: 1.   How to check the name and path of the files

HDF5 Files using pandas HDFStore - Cheatsheet


In this blog we will create cheat-sheet, or reference material where in we will cover the main functionalities for accessing the data from HDF5 Files in Python using pandas HDFStore. 


►  The HDFStore class is the pandas abstraction, responsible for dealing with HDF5 data. 

  • Under the hood HDFStore uses the PyTables library, so make sure that it is installed, if you want to use this format.

►  Give the HDFStore constructor the path to a demo file and create a store:

    filename = "pytable_df_file.h5"
    store = 

►  HDFStore has a dictionary like interface, which means we can store key-value pairs, for example: a pandas DataFrame with a corresponding lookup key.

►  Store a DataFrame which contains your data in HDFStore as follows. The key is 'df' here (same is highlighted below), and the DataFrame object is df.

    store['df'] = df 

►  Save the DataFrame back to HDF5

  • This is quite simple, simply assign back the df to HDF5 file, as mentioned in below line

    store['df'] = changed_df 

►  We can access the DataFrame in three ways:

    1.  First with the get() method

    print("Get", store.get('df').shape) 

    2. Dictionary like lookup 

    print("Lookup", store['df'].shape) 

    3. And finally the dotted access 

    print("Dotted", store.df.shape) 

►  We can delete an item from the store by calling the remove() method, or with the del operator.

    del store['df'] 
    print("After del\n", store) 

►  The is_open attribute indicates whether the store is open or not. 

►  The store can be closed with the close() method. In below sample we will close the store and check again that it got closed or not:

    print("Before close", store.is_open) 
    print("After close", store.is_open) 

►  Pandas also provides a DataFrame to_hdf() method, and a top-level read_hdf() function to read and write HDF5 data. In below snippet we will call the to_hdf() method and read the data:

    df.to_hdf(, 'data', format='table') 
    print(pd.read_hdf(, 'data', where=['index>363']))


Using this cheat-sheet you should be able to start coding the needed functionality. 


Your feedback

Your feedback is of paramount importance to us, provide your valuable inputs; what else you would like to read about, or if you would like the author to elaborate on any specific topic from this article, or any other article on this blog.


The material presented in this blog is to help educate the developers, and the author(s) & owner(s) of this blog are not responsible of any damage arising out of use of the code snippets or any other contents of this blog.