posts
posts copied to clipboard
`%sqlcmd columns` outputs sql.inspect.Columns
Hi
Objective: Using the %sqlcmd columns
I like to access the column names (as a dataframe or series or list) of tables in a database.
What I did:
Cell#1:
%sql USE DATABASE {DB Name} %sqlcmd columns --table {Table Name} --schema {Schema Name}
Cell#2: (to capture the previous result)
df = _
Cell#3: (to know the data type of the result)
type(df)
output: sql.inspect.Columns
Hence I'm not able to apply any methods or functions to convert this into a dataframe or series or list.
Q1: Is there a way I can access the output as a dataframe instead of sql.inspect.Columns Q2: Is there a way to consolidate cell#1 & 2. Is there a way to directly store the output of %sqlcmd into a variable directly.