Python Forum

Full Version: How read Table Structure from Database
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

I want to read the table description for particular table database and create the hive QL (HQL) statement
to create table in Hive using python code.

Can anyone please help how this can be achieved.

Thanks,
you didn't say the DBMS name.
Most have a way to display the schema.
If sqlite3:
install sqlite3, on Linux Mint, use:
sudo apt install sqlite3
You will have to look up command for other systems, see: https://sqlite.org/download.html

from command line:
  • sqlite3 yourdbname
  • sqlite> .output 'schema.txt'
  • sqlite> .schema
  • sqlite> .quit
I want to handle it in script data base will be anyone Oracle,Mysql.

Script should connect to database and fetch the table structure of table which is passed in script
A few years ago, I wrote a small script to print the structure of an sqlite database from python. I hope it helps.
Hi All...
I am trying to make a list from the table values I retrieved using below method
Code:

tabledata=browser.get_table_data("Xpath__//div[@class='col-md-12 hui-display']/div/div")
#print("printing table data")
#print(tabledata)
if(len(tabledata)>0):
import pandas as pd
pd.set_option('display.max_columns',None)
table_df=pd.DataFrame(tabledata)
print("printing the data frame")
print(table_df)

I am getting data in a not so defined formatt

How do I get data from a table with all the header and keep it in a list to compare it with my test data. Please help me out understand this
hemasri ... Please start your own thread.
Your post has nothing to do with this thread and doesn't belong here.