Skip to main content

A sql robot logger

Project description

README

Creates and updates a robot state logging database.

This program allows you to log information to different topics stored in a database file, extract subsets based on certain condition, as well as converting such selections into pandas dataframes.

Example

  1. Create a config.yml file in the home directory that mirrors the following

      log_info:
         database_name:
         robot_id: 
      sql_database:
         host: 
         password: 
         port: 
         user:
    
    • if robot_id is left blank, then one is assigned based on the next available robot_id in the database
  2. Create the state logger object and give it a unique id and a database to write to (if left blank, one will automatically be created)

          import robot_logger.robot_logger as rl
          robot_logger = rl.RobotLogger()
    
  3. Add a topic and its respective data type

         robot_logger.add_topic("test_topic", int)
    
  4. Add integer message with the topic and allow for local backup

         robot_logger.write("test_topic", 1234, str(__file__), True)
    
  5. Create the database inspector

         import robot_inspector.robot_inspector as ri
         robot_inspector = ri.SQLInspector()
    
  6. Generate a query from the log table that match a custom condition

         query = robot_inspector.get_query("log","topic_id = 1")
    
  7. Display the list of matches

         print(query)
    
  8. Generate a pandas data frame from the query

         df = q.get()
    

Run instructions

Note, only tested with Python 3

  1. Clone the repository

    git clone git@github.com:adamhamden/aws-sql-logger-interface.git
    
  2. Go in the cloned directory

     cd aws-sql-logger-interface
    
  3. Start a virtual environment

     virtualenv -p python3 venv
     source venv/bin/activate
    
  4. Install the requirements

     pip install -r requirements.txt
    
  5. Check that the tests run

     python -m unittest test.py
    
  6. Import and use the module!

Project details


Download files

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

Source Distribution

sql_robot_logger-0.1.1.tar.gz (5.7 kB view details)

Uploaded Source

File details

Details for the file sql_robot_logger-0.1.1.tar.gz.

File metadata

  • Download URL: sql_robot_logger-0.1.1.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.1.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.1

File hashes

Hashes for sql_robot_logger-0.1.1.tar.gz
Algorithm Hash digest
SHA256 feb75ed232ccb3af74c00788f08359613bf7332b2a4d235ba4da46c1bf7ae412
MD5 6b278bb1e86c7fbe848417c1318cdfd0
BLAKE2b-256 08aa670f8a1212b5dfce0d04a46bcc180d518edda84fd28737b0fc73c6c65518

See more details on using hashes here.

Supported by

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