# Viewing Table Details

# Great job reflecting the census table! Now you can begin to learn more 
# about the columns and structure of your table. It is important to get 
# an understanding of your database by examining the column names. This 
# can be done by using the .columns attribute and accessing the .keys() 
# method. For example, census.columns.keys() would return a list of 
# column names of the census table.

# Following this, we can use the metadata container to find out more 
# details about the reflected table such as the columns and their types. 
# For example, table objects are stored in the metadata.tables 
# dictionary, so you can get the metadata of your census table with 
# metadata.tables['census']. This is similar to your use of the repr() 
# function on the census table from the previous exercise.

# Instructions

# Reflect the census table as you did in the previous exercise using the 
# Table() function.

# Print a list of column names of the census table by applying the 
# .keys() method to census.columns.

# Print the details of the census table using the metadata.tables 
# dictionary along with the repr() function. To do this, first access 
# the 'census' key of the metadata.tables dictionary, and place this 
# inside the provided repr() function.

# Reflect the census table from the engine: census
census = Table('census', metadata, autoload=True, autoload_with=engine)

# Print the column names
print(census.columns.keys())

# Print full table metadata
print(repr(metadata.tables['census']))

In [2]: census.columns.keys()
Out[2]: ['state', 'sex', 'age', 'pop2000', 'pop2008']

In [3]: # Reflect the census table from the engine: census
        census = Table('census', metadata, autoload=True, autoload_with=engine)
        
        # Print the column names
        print(census.columns.keys())
        
        # Print full table metadata
        print(repr(metadata.tables['census']))
['state', 'sex', 'age', 'pop2000', 'pop2008']
Table('census', MetaData(bind=None), Column('state', VARCHAR(length=30), table=<census>), Column('sex', VARCHAR(length=1), table=<census>), Column('age', INTEGER(), table=<census>), Column('pop2000', INTEGER(), table=<census>), Column('pop2008', INTEGER(), table=<census>), schema=None)