Search
 
SCRIPT & CODE EXAMPLE
 

SQL

how to get column name in db from an sqlalchemy attribute model

class User(Base):
    __tablename__ = 'user'
    id = Column('id', String(40), primary_key=True)
    email = Column('email', String(50))
    firstName = Column('first_name', String(25))
    lastName = Column('last_name', String(25))
    addressOne = Column('address_one', String(255))


from sqlalchemy.inspection import inspect
# columns = [column.name for column in inspect(model).c]

# Also if we want to know that User.firstName is first_name then:
columnNameInDb = inspect(User).c.firstName.name
# The following will print: first_name
print(columnNameInDb)
Comment

PREVIOUS NEXT
Code Example
Sql :: change password in mysql 
Sql :: tsql edit table column 
Sql :: order by sql query 
Sql :: java sql insert return id 
Sql :: change database postgres 
Sql :: how to use query in nosql 
Sql :: mysql delete older duplicates 
Sql :: sql cheat sheet 
Sql :: how to put is null in where in clause 
Sql :: between date in sql server 
Sql :: sql exemplos 
Sql :: select only distinct values from another table 
Sql :: sql comments 
Sql :: having clause 
Sql :: how to get information about data types in postgreSQL 
Sql :: hibernate show sql xml property 
Sql :: connect to mysql server mac terminal 
Sql :: check if table is Temporal 
Sql :: how to check common records in 2 table 
Sql :: how to replace null values in sql 
Sql :: sql order 
Sql :: oracle disk group space 
Sql :: oracle INTERVAL DAY to second to number 
Sql :: sql union 
Sql :: postgresql like 
Sql :: oracle sql trigger select into 
Sql :: import Data in MySQL without using any other software 
Sql :: how to increase the width of the screen in oracle 
Sql :: how to reset the identity column in sql server 
Sql :: equi joins in oracle 
ADD CONTENT
Topic
Content
Source link
Name
8+9 =