Skip to main content

Tools for the Row64 Platform

Project description

row64tools is a set of server and workflow tools for the Row64 Platform. In the current version, it's primary use is writting database connectors to the Row64 Server.

Data in the Row64 Server is based on the .ramdb format. This is a extremely fast and flexible format for loading data into dashboards. You can think of it like a low-level JSON for byte streams. Typically .ramdb files store a single dataframe / table.

Dataframe to .ramdb

Here's an example showing how to save a dataframe into .ramdb format:

import pandas as pd
from row64tools import ramdb

data = {"txt": ["a","b", "c"],"num": [1, 2, 3]}
df = pd.DataFrame(data)
ramdb.save_from_df(df, "/home/row64/Downloads/testSave.ramdb")

Working With Dates

Dates are a critical part of working with business dashboards.

All you need to remember is to use pd.to_datetime tell pandas your date columns are dates.

row64tools then correctly convert them to dates in your dashboard.

Here's an example:

import pandas as pd
from row64tools import ramdb

data = {
  "tier": [4, 2, 1],
  "active": [False, True, False],
  "name": ["David", "Mary", "John"],
  "points": [10.5, 6.5, 8.0],
  "sign up": ["09/01/2017","07/14/2022","04/03/2015"]
}
df = pd.DataFrame(data)
df["sign up"] = pd.to_datetime(df["sign up"])

ramdb.save_from_df(df, "/home/row64/Downloads/testSave.ramdb")

Database Connector

Next lets look at how to save a .ramdb into the Row64 Server on Linux.

Ramdb files are stored in: /var/www/ramdb

The running server is connected to the files in the live folder. For example when we load the Amazon Reviews demo, it uses the table:

/var/www/ramdb/live/RAMDB.Row64/Examples/AmazonReviews.ramdb

You can see the sub-folders tell the server about the table:

live
  └── RAMDB.Row64
              └── Examples
                        └── AmazonReviews.ramdb
  • RAMD.Row64 is the connector for each database type
  • Examples is the group or folder of tables
  • AmazonReviews.ramdb is the table name

For a simple test - lets upload in the Temp folder and restart the server:

import pandas as pd
from row64tools import ramdb

data = {"txt": ["a","b", "c"],"num": [1, 2, 3]}
df = pd.DataFrame(data)
ramdb.save_from_df(df, "/var/www/ramdb/live/RAMDB.Row64/Temp/Test.ramdb")

In practice this is not very good for a running dashboard sever with many users.
Especially when you are updating frequent changes to a table. It's much better to upload new files without restarting the server. So to do this you place the file into the loading folder. Row64 Server will watch that folder and wait for a moment when the file is not being accessed. It will swap it out and pull it into RAM.

This is pretty simple, the only detail is to make sure you have a matching folder structure for where you want it to end up in the live folder:

import pandas as pd
from row64tools import ramdb
from pathlib import Path

data = {"txt": ["a","b", "c"],"num": [1, 2, 3]}
df = pd.DataFrame(data)
Path("/var/www/ramdb/loading/RAMDB.Row64/Temp").mkdir(parents=True, exist_ok=True)
ramdb.save_from_df(df, "/var/www/ramdb/loading/RAMDB.Row64/Temp/Test.ramdb")

The server will check every minute or so for changes. The frequency of update is based on your .config file RAMDB_UPDATE setting. If you run the example while the server is running you'll see the file in:

/var/www/ramdb/loading/RAMDB.Row64/Temp/Test.ramdb

But if you check back a minute later, you'll see the file is gone and has moved into the live folder.

Loading .ramdb files

You can also load and run diagnostics on .ramdb files.

row64tools also include a .ramdb for testing in the function .example_path()

In this example we load and run diagnostics with: json, pandas dataframe, and numpy:

from row64tools import ramdb

ePath = ramdb.example_path()
print(ePath)

print("\n---------------- log ramdb to json string ----------------") 
ejson = ramdb.load_to_json(ePath)
print(ejson)

print("\n--------------- load ramdb to dataframe ---------------") 
df = ramdb.load_to_df(ePath)
print(df)

print("\n------------- load ramdb to numpy objects -------------")
npObj = ramdb.load_to_np(ePath)
print("Number of Columns: ", npObj['NbCols'])
print("Number of Rows: ", npObj['NbRows'])
print("Column Names: ", npObj['ColNames'])
print("Column Types: ", npObj['ColTypes'])
print("Column Sizes: ", npObj['ColSizes'])
print("Column Format: ", npObj['ColFormat'])
print("Columns[0] Values: ", npObj['Tables'][0])
print("Columns[1] Values: ", npObj['Tables'][1])
print("Columns[2] Values: ", npObj['Tables'][2])

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

row64tools-1.0.11.tar.gz (7.8 MB view details)

Uploaded Source

Built Distribution

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

row64tools-1.0.11-py3-none-any.whl (7.9 MB view details)

Uploaded Python 3

File details

Details for the file row64tools-1.0.11.tar.gz.

File metadata

  • Download URL: row64tools-1.0.11.tar.gz
  • Upload date:
  • Size: 7.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for row64tools-1.0.11.tar.gz
Algorithm Hash digest
SHA256 00f14faf6c6fbe026c1f6efaccb88fda5e140f5578f380f95bdef5b6916e3c2f
MD5 01d5806e2ce4a21854b7a4236fc665ff
BLAKE2b-256 d08ef67d39457297c2860d5d7f5f8383242e918db9d94e223b4f58f4985c030a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: row64tools-1.0.11-py3-none-any.whl
  • Upload date:
  • Size: 7.9 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for row64tools-1.0.11-py3-none-any.whl
Algorithm Hash digest
SHA256 217b5e06dad007ee08d279b6a9149141501e9468cd71e4a463ad8a2e7a595ca1
MD5 0af56c76a95a0e3b1be026b1e5cb010b
BLAKE2b-256 2554d2fb19423a36c09f7712c70d7551b0279642488c57e8c7ec3d7076941b07

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