uh in this video we will see how we can
extract our table name and column names
from kodi using python library so i'm
going to use a sql metadata here
to extract the table name and color
names
let's see how we can do this
i have opened a database notebook here
so i'm going to use this sql data
library
you can you can install using this
command pip install ask library sql
metadata
and if you want to know about more
information about this library you can
go into the documentation i'll just put
this in the link
yeah i've just installed this one so
next what i'm going to do is i'm going
to import this one in in my
code
so from sql data import parser
and i have data variable one i have a
string here this is my query select star
from table a comma table b
and i'm gonna what i'm gonna use the
parser i'm gonna pass variable variable
one and dot tables when you run this
particular command it will gives me
the table name from the
variable for example in this case a
variable has two very two tables name
tablea comma table b so when i use this
function parser.tables which will gives
me the output of stability comma table b
uh next i'll give an example where we
have a sub query
in in my example
the where i've declared a variable of
that too so this is my query so let's
start from tableau commercially by
column one in select
column one in from column table c so i
have three tables here terabit table
comma table b and table c i'm gonna use
the same function here and if you
display this one
it will show three tables table y table
b comma table c
uh similarly it's not one from select
query if you want to get the query from
the insert query also for example in my
case variable three equal to insert into
table a values one comma two and when
use the same function parser variable
three dot tables
this will display uh that table name
from the insert query so this is my
inside query and the table name is table
ya so that's what you could see in the
table see
similarly is just not the table name if
you want to get the allies from the
table also you can use
this library
for example variable 4 i will declare
ls for table esa
and table bsb and table csc
i'm going to use this function parser
dot table underscore analysis
so if you're on this query i mean on
this uh command you will get the output
as uh
like this the table uh the ssa and for
table b alleles is b and c lssc so yeah
this is what we could i mean we can run
the query and get the run this for
command and get the output
and next we'll see how we can extract
column names from the query so i've
declared variables six here with the
query here the string so this is my
string
so i have column x column y then column
x and from table c
and there you want to use parser dot
columns so this will list all the
columns from the uh query
so column x and column y so if you see
here i have column x
twice thrice here for the column x here
we have one column x here column x here
as well as column x
i mentioned three i mean we have three
column columns with the same name
so when it displays output it just shows
only one column
one column name
okay so just a unique it will give the
unique output in the list
next the same thing like we can do with
what with the variables which have
declared above variable one two and
three
for example if you see here in variable
one i don't have any columns here just
dimensional star here
and also in column two also mentioned
the star here and i have column here in
this particular sub query yeah so this
is one
the my third example i went to insert
query there is no column i mentioned
here so when you execute this particular
command uh you will find the output
desktop because i don't have any
mentioned any column just a star i
mentioned in the first variable so i get
a star here the next next variable i
mentioned star as well as column one so
we'll get the output
star comma column one
and third list and the third uh variable
i
use insert there is no column mentioned
so i just give a blank statement i make
a blank list empty list uh yeah so if
you want more information about this
exemplary data you can get uh go into
this library and get this documentation
get all those information and there are
other different types of functionality
functions are there you can use those
functions to derive your uh
derive your exposure things
yeah so i've used the i've used this
library just to show how we can take the
table name x and the column names from
the
query
that's it for now thanks for watching