Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Synopsis
- data CSVHeader
- newtype Chunks = Chunks {}
- data CSVType
- newtype ColumnName = ColumnName {}
- data ColumnWithType = ColumnWithType {}
- type CsvSchema = NonEmpty ColumnWithType
- newtype CSVError = CSVError Text
- class CSVImport bk where
- chunkLimit :: Int
- isEnabled :: Bool
- type CSVContext m bk = (CSVImport bk, MonadNapkin bk m, Command (CreateTable (BackendTableMeta bk)) () bk, Command InsertIntoQuery () bk, MonadThrow m)
- createTableQuery :: CsvSchema -> Query
- readAndCheckHeader :: (Monad m, MonadThrow m) => CSVHeader -> CsvSchema -> ConduitT (Row Text) b (ResourceT m) (Maybe [Maybe ColumnWithType])
- loadCSV :: forall bk m. CSVContext m bk => CSVSettings -> BackendConn bk -> Ref Table -> SpecPaths -> FilePath -> CSVHeader -> Chunks -> CsvSchema -> m ()
- loadDb :: forall bk m. CSVContext m bk => BackendConn bk -> Ref Table -> CSVHeader -> Chunks -> CsvSchema -> ConduitT [Text] Void (ResourceT m) ()
- insertTableQueries :: CSVContext m bk => BackendConn bk -> Ref Table -> Maybe [Maybe ColumnWithType] -> CsvSchema -> [[Text]] -> m ()
- match :: Maybe [Maybe ColumnWithType] -> CsvSchema -> [Text] -> Either Text [(ColumnWithType, Text)]
- insertTableQuery :: [(ColumnWithType, Text)] -> Either Text Query
- parseSExp :: ColumnName -> CSVType -> Text -> Either Text SExp
- anyDayFormatParser :: ReadP Day
- parseAnyDay :: String -> Either Text Day
- parseResult :: [(b, String)] -> Either Text b
- anyDateTimeParser :: ReadP UTCTime
- parseAnyDateTime :: String -> Either Text UTCTime
Documentation
Instances
FromJSON CSVType # | |
ToJSON CSVType # | |
Defined in Napkin.Run.Effects.CSV.CSVImport | |
Bounded CSVType # | |
Enum CSVType # | |
Generic CSVType # | |
Show CSVType # | |
Eq CSVType # | |
type Rep CSVType # | |
Defined in Napkin.Run.Effects.CSV.CSVImport type Rep CSVType = D1 ('MetaData "CSVType" "Napkin.Run.Effects.CSV.CSVImport" "napkin-0.5.14-JrXUGmKUOt9J0meJSj0Kh4" 'False) ((C1 ('MetaCons "CSVTyInteger" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "CSVTyDouble" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "CSVTyDate" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "CSVTyDateTime" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "CSVTyText" 'PrefixI 'False) (U1 :: Type -> Type)))) |
newtype ColumnName #
Instances
IsString ColumnName # | |
Defined in Napkin.Run.Effects.CSV.CSVImport fromString :: String -> ColumnName # | |
Show ColumnName # | |
Defined in Napkin.Run.Effects.CSV.CSVImport showsPrec :: Int -> ColumnName -> ShowS # show :: ColumnName -> String # showList :: [ColumnName] -> ShowS # | |
Eq ColumnName # | |
Defined in Napkin.Run.Effects.CSV.CSVImport (==) :: ColumnName -> ColumnName -> Bool # (/=) :: ColumnName -> ColumnName -> Bool # |
data ColumnWithType #
Instances
FromJSON ColumnWithType # | |
Defined in Napkin.Run.Effects.CSV.CSVImport parseJSON :: Value -> Parser ColumnWithType # parseJSONList :: Value -> Parser [ColumnWithType] # | |
Show ColumnWithType # | |
Defined in Napkin.Run.Effects.CSV.CSVImport showsPrec :: Int -> ColumnWithType -> ShowS # show :: ColumnWithType -> String # showList :: [ColumnWithType] -> ShowS # | |
Eq ColumnWithType # | |
Defined in Napkin.Run.Effects.CSV.CSVImport (==) :: ColumnWithType -> ColumnWithType -> Bool # (/=) :: ColumnWithType -> ColumnWithType -> Bool # |
type CsvSchema = NonEmpty ColumnWithType #
Instances
Exception CSVError # | |
Defined in Napkin.Run.Effects.CSV.CSVImport toException :: CSVError -> SomeException # fromException :: SomeException -> Maybe CSVError # displayException :: CSVError -> String # | |
Show CSVError # | |
Eq CSVError # | |
chunkLimit :: Int #
backend limit on inserts union size
to exclude backends, for example: BigQuery for which this mechanism is not compatible and bigquery-tools should be used
Instances
CSVImport BigQuery # | |
Defined in Napkin.Run.BigQuery | |
CSVImport MsSql # | |
Defined in Napkin.Run.MsSql | |
CSVImport Postgres # | |
Defined in Napkin.Run.Postgres | |
CSVImport Redshift # | |
Defined in Napkin.Run.Redshift | |
CSVImport Sqlite # | |
Defined in Napkin.Run.Sqlite |
type CSVContext m bk = (CSVImport bk, MonadNapkin bk m, Command (CreateTable (BackendTableMeta bk)) () bk, Command InsertIntoQuery () bk, MonadThrow m) #
createTableQuery :: CsvSchema -> Query #
Generates an empty select query with the specified columns in Schema argument for table creation
readAndCheckHeader :: (Monad m, MonadThrow m) => CSVHeader -> CsvSchema -> ConduitT (Row Text) b (ResourceT m) (Maybe [Maybe ColumnWithType]) #
loadCSV :: forall bk m. CSVContext m bk => CSVSettings -> BackendConn bk -> Ref Table -> SpecPaths -> FilePath -> CSVHeader -> Chunks -> CsvSchema -> m () #
loadDb :: forall bk m. CSVContext m bk => BackendConn bk -> Ref Table -> CSVHeader -> Chunks -> CsvSchema -> ConduitT [Text] Void (ResourceT m) () #
insertTableQueries :: CSVContext m bk => BackendConn bk -> Ref Table -> Maybe [Maybe ColumnWithType] -> CsvSchema -> [[Text]] -> m () #
match :: Maybe [Maybe ColumnWithType] -> CsvSchema -> [Text] -> Either Text [(ColumnWithType, Text)] #
insertTableQuery :: [(ColumnWithType, Text)] -> Either Text Query #
parseResult :: [(b, String)] -> Either Text b #