Python Forum
How read Table Structure from Database
Thread Rating:
  • 2 Vote(s) - 2 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How read Table Structure from Database
#1
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,
Reply
#2
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
Reply
#3
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
Reply
#4
A few years ago, I wrote a small script to print the structure of an sqlite database from python. I hope it helps.
Reply
#5
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
Reply
#6
hemasri ... Please start your own thread.
Your post has nothing to do with this thread and doesn't belong here.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Pymodbus read and save to database stewietopg 3 1,854 Mar-02-2023, 09:32 AM
Last Post: stewietopg
  Read JSON via API and write to SQL database TecInfo 5 2,188 Aug-09-2022, 04:44 PM
Last Post: TecInfo
  SaltStack: MySQL returner save less data into Database table columns xtc14 2 2,157 Jul-02-2021, 02:19 PM
Last Post: xtc14
  Yahoo_fin, Pandas: how to convert data table structure in csv file detlefschmitt 14 7,736 Feb-15-2021, 12:58 PM
Last Post: detlefschmitt
  Looping to read data in database CEC68 1 1,704 Sep-24-2020, 08:54 PM
Last Post: scidam
  Database structure (no code?) BlackmoreSteve620721 1 1,826 Apr-13-2020, 10:39 PM
Last Post: Larz60+
  MYSQL how to assign a table for each user in my username table database? YoshikageKira 1 2,801 Dec-26-2019, 05:57 AM
Last Post: buran
  Database table structure compare(Oracle) GKT 4 2,755 Oct-16-2019, 03:16 PM
Last Post: GKT
  Check table exists in Database ARV 0 1,940 Oct-03-2019, 02:37 PM
Last Post: ARV
  How do i read particular text from text file and update those values in MS SQL table ganeshsai2912 33 14,842 Nov-20-2018, 12:55 AM
Last Post: ganeshsai2912

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020