Created
July 21, 2016 19:58
-
-
Save bklein01/dd18277a76ab0bf5629362c36b4f5962 to your computer and use it in GitHub Desktop.
Quick SQL to help build TypeScript Model Classes For a Database/Restful API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT CONCAT(column_name, ': ', (CASE data_type WHEN 'bigint' THEN 'number' WHEN 'smallint' THEN 'number' WHEN 'char' THEN 'string' WHEN 'tinyint' THEN 'number' WHEN 'int' THEN 'number' WHEN 'varchar' THEN 'string' WHEN 'text' THEN 'string' WHEN 'timestamp' THEN 'string' WHEN 'date' THEN 'string' WHEN 'datetime' THEN 'string' WHEN 'decimal' THEN 'number' END), ';') | |
FROM information_schema.columns | |
WHERE table_name = '{tablename}' AND table_schema = '{database}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment