html_url,issue_url,id,node_id,user,user_label,created_at,updated_at,author_association,body,reactions,issue,issue_label,performed_via_github_app https://github.com/simonw/sqlite-utils/issues/11#issuecomment-466695695,https://api.github.com/repos/simonw/sqlite-utils/issues/11,466695695,MDEyOklzc3VlQ29tbWVudDQ2NjY5NTY5NQ==,9599,simonw,2019-02-23T21:10:35Z,2019-02-23T21:10:35Z,OWNER,Need to test this both with and without `numpy` installed.,"{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",413740684,Detect numpy types when creating tables, https://github.com/simonw/sqlite-utils/issues/11#issuecomment-466695672,https://api.github.com/repos/simonw/sqlite-utils/issues/11,466695672,MDEyOklzc3VlQ29tbWVudDQ2NjY5NTY3Mg==,9599,simonw,2019-02-23T21:10:23Z,2019-02-23T21:10:23Z,OWNER,"Rough sketch: ``` +try: + import numpy +except ImportError: + numpy = None + Column = namedtuple( ""Column"", (""cid"", ""name"", ""type"", ""notnull"", ""default_value"", ""is_pk"") ) @@ -70,6 +79,22 @@ class Database: datetime.time: ""TEXT"", None.__class__: ""TEXT"", } + # If numpy is available, add more types + if numpy: + col_type_mapping.update({ + numpy.int8: ""INTEGER"", + numpy.int16: ""INTEGER"", + numpy.int32: ""INTEGER"", + numpy.int64: ""INTEGER"", + numpy.uint8: ""INTEGER"", + numpy.uint16: ""INTEGER"", + numpy.uint32: ""INTEGER"", + numpy.uint64: ""INTEGER"", + numpy.float16: ""FLOAT"", + numpy.float32: ""FLOAT"", + numpy.float64: ""FLOAT"", + numpy.float128: ""FLOAT"", + }) ```","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",413740684,Detect numpy types when creating tables,