Metadata-Version: 2.1
Name: afs2-datasource
Version: 2.1.15
Summary: For AFS developer to access Datasource
Home-page: https://github.com/stacy0416/afs2-datasource
Author: WISE-PaaS/AFS
Author-email: stacy.yeh@advantech.com.tw
License: Apache License 2.0
Description: # AFS2-DataSource SDK
        The AFS2-DataSource SDK package allows developers to easily access PostgreSQL, MongoDB, InfluxDB.
        
        ## Installation
        Support Pyton version 3.6 or later
        ```
        pip install afs2-datasource
        ```
        
        ## Example
        ### Database config
        Database config from environment variable.
        
        Export database config on command line.
        ```base
        export PAI_DATA_DIR="{"type": "mongo-firehose","data": {"dbType": "internal","querySql": "{QUERY_STRING}","collection": "{COLLECTION_NAME}","credential": {"username": "{DB_USERNAME}","password": "{DB_PASSWORD}","database": "{DB_NAME}","port": {DB_PORT},"host": "{DB_HOST}"}}}"
        ```
        
        Export database config via Python
        ```python
        os.environ['PAI_DATA_DIR'] = {
            "type": "mongo-firehose",
            "data": {
              "dbType": "internal",
              "querySql": "{QUERY_STRING}",
              "collection": "{COLLECTION_NAME}",
              "credential": {
                "username": "{DB_USERNAME}",
                "password": "{DB_PASSWORD}",
                "database": "{DB_NAME}",
                "port": {DB_PORT},
                "host": "{DB_HOST}"
              }
            }
          }
        ```
        
        ### DBManager Example
        ```python
        from afs2datasource import DBManager
        
        # Init DBManager
        manager = DBManager()
        
        # Connect DB
        manager.connect()
        
        # Execute querySql in DB config
        data = manager.execute_query()
        # Return type: DataFrame 
        """
              Age  Cabin  Embarked      Fare  ...  Sex  Survived  Ticket_info  Title2
        0    22.0    7.0       2.0    7.2500  ...  1.0       0.0          2.0     2.0
        1    38.0    2.0       0.0   71.2833  ...  0.0       1.0         14.0     3.0
        2    26.0    7.0       2.0    7.9250  ...  0.0       1.0         31.0     1.0
        3    35.0    2.0       2.0   53.1000  ...  0.0       1.0         36.0     3.0
        4    35.0    7.0       2.0    8.0500  ...  1.0       0.0         36.0     2.0
        ...
        """
        
        ```
        
        ## API List
        + connect()
        + disconnect()
        + is_connected()
        + is_connecting()
        + get_dbtype()
        + execute_query()
        + create_table(table_name, columns)
        + is_table_exist(table_name)
        + insert(table_name, columns, records)
Keywords: AFS
Platform: UNKNOWN
Description-Content-Type: text/markdown
