I have a nasty error with no direction when using factory boy to make fake models:
DataError: value too long for type character varying(2)
Is there a pythonic (or ruby) way to print out only the names of columns that are varchar(2) type in the database? I'd assume it's in some pgadmin3 metadata? Thank you
For a Postgres query, I think this does what you're looking for.
SELECT column_name FROM information_schema.columns WHERE table_name='some_table' AND data_type='varchar(2)';
This just selects all the varchar(2)
columns in a specific table, but you can drop that part to get them throughout the entire database. You can also add in table_schema='some_schema'
for just a certain schema in the database.
As far as a pythonic or ruby way to do it, I don't know of one, other than running that query in psycopg or some other Postgres adapter.
More info on information_schema.columns
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.