Skip to main content

easydetabase interact with deta base service in easy way

Project description

easydetabase (easy-detabase)

Easydetabase( or easydetabase) offer a simple way to interact with Deta Base Service. This library was built on top of deta official library

Functionalities

Currently easy-detabase have three operations/functions:

  • bulk_insert_to_deta

    Function provide a way to insert records loaded in csv file, separated by separator in deta base table

    Usage Mode:

        from easydetabase import bulk_insert_to_deta
        from deta import Deta
        import pandas as pd 
        
        if __name__ == '__main__':
        
            deta = Deta("project key")
            db = deta.Base("sample_db")
            csv_path_file = './files/countries.csv'
            separator = ';'
            df_deta = pd.read_csv(csv_path_file, sep = separator)
            bulk_insert_to_deta(df_deta, db, 1)
    

    Output message:

    if insertion goes ok the message is:

            Chunk step 1
            245 records was inserted
    

    but if you have some issue on insertion process, message is

           HTTP Error 400: Bad Request
           Something was wrong with some record.
           Put value 1 to insert record and check the issue
           Suggestion: is good idea create output.log file if you try insert a lot of records;
           in that way you can find the error message on it and check.
           Chunk step 1
           244 records was inserted
           1 records was no inserted
    
  • deta_table_to_dataframe

    Function provide a way to read a deta base table and return a pandas dataframe to work on it.

    Usage Mode

        from easydetabase import deta_table_to_dataframe
        from deta import Deta
        
        if __name__ == '__main__':
        
            deta = Deta("project key")
            db = deta.Base("sample_db")
            fetch_res = db.fetch()
            df = deta_table_to_dataframe(fetch_res)
            print(df)
    

    Output message:

    You can see something this in terminal:

              country       fecha           key
        1          AU  2022-11-04  0cgr087icsk2
        3          DO  2022-11-04  0oymhwaqo7oa
        0          HM  2022-11-04  09upg9ncmite
        4          LK  2022-11-04  0r9lesxgf31p
        2          WF  2022-11-04  0j0l002gabpy
    
  • truncate_deta_table

    Function provide a way to truncate a deta base table.

    Usage Mode

        from easydetabase import truncate_deta_table
        from deta import Deta
    
        if __name__ == '__main__':
        
            deta = Deta("project key")
            db = deta.Base("sample_db")
            truncate_deta_table(db)
    

    Output message:

    Out message must be like:

         244 rows was deleted
    

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

easydetabase-1.0.11-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file easydetabase-1.0.11-py3-none-any.whl.

File metadata

  • Download URL: easydetabase-1.0.11-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.10

File hashes

Hashes for easydetabase-1.0.11-py3-none-any.whl
Algorithm Hash digest
SHA256 a02e0be39bad0ca7e89d75b592cbedd8de3b5148a2208bef478d0b3a48d8281e
MD5 ebb2f0e6beffba699ec9613b0b07bf25
BLAKE2b-256 39d65c7a36cb2f4d7e3462addce5b098fe907547f7b1c76e1abeb7828e78f42c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page