Category: Data Science

How To Get/Set Current Database Name in Hive

It is very easy to find/display current database information in Hive Command Line Interface (CLI). Just run the below command and terminal will display the current Hive database you are connected to.

hive> set hiveconf:hive.cli.print.current.db=true;
 hive (my_db)>

This value will be overwritten if you restart the Hive CLI or you open a new one. We can set it my permanently by editing the

~/.hiverc file.

restart the hive CLI after updating the file and it will show which DB you are connected to.

hive (default)> use my_db ;
 OK
 Time taken: 3.189 seconds
 hive (my_db)>

Finding Python & Modules version

This is how you can find python and installed modules version.

#import the sys module which contains the version function.

>>> import sys
>>> print ‘Installed Python version is :’, sys.version

Installed Python version is : 2.4.3 (#1, Oct 23 2012, 22:02:41)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-54)]

For other modules we can use the __version__ function. To find the version of csv module,

>>> import csv
>>> print ‘CSV module version is’, csv.__version__

1.0

This method may not work for all modules, but in my experience it works for most of the modules.