Reputation: 728
I use MySQLdb(a python library) to talk with mysql. Is there some way to get the field type using MySQLdb , and the most important thing is how can I know it is unsigned or not ?
I know we can use MYSQL_FIELD struct to get what I mentioned above using mysql C api. Is there something similar in MySQLdb ?
Thank you very much!
Upvotes: 1
Views: 95
Reputation: 149823
You can get the field type from the INFORMATION_SCHEMA Tables, e.g.
SELECT COLUMN_NAME, COLUMN_TYPE
FROM INFORMATION_SCHEMA.COLUMNS
WHERE table_name = 'tbl_name'
Upvotes: 1
Reputation: 798744
No. There is no provision in MySQLdb (not even via _mysql
) for calling mysql_fetch_fields()
. You will either have to patch it in, get someone else to do it, or find some way to do it in SQL.
Upvotes: 1