Skip to main content

A data model based on in-memory sqlite

Project description

SQLDataModel

SQLDataModel is a speedy & lightweight data model with no external dependencies for quickly fetching and storing your tabular data

Installation

Use the package manager pip to install the package when its uploaded.

pip install name-not-yet-determined # working on it!

Usage

import SQLDataModel

# create a SQLDataModel object from any valid source:
sdm = SQLDataModel.from_csv('world-cup-2022.csv')

# manipulate it
sdm_sliced = sdm.get_rows_at_index_range(1,4)

# loop through it:
for row in sdm_full.iter_rows():
    print(row)

# view it as a table
print(sdm)

┌────┬─────────────┬────────┬────────────┐
     team           rank  federation 
├────┼─────────────┼────────┼────────────┤
  1  Argentina         3  CONMEBOL   
  2  Brazil            1  CONMEBOL   
  3  Ecuador          44  CONMEBOL   
  4  Uruguay          14  CONMEBOL   
  5  Belgium           2  UEFA       
  6  Croatia          12  UEFA       
  7  Denmark          10  UEFA       
  8  England           5  UEFA       
  9  France            4  UEFA       
 10  Germany          11  UEFA       
 11  Netherlands       8  UEFA       
 12  Poland           26  UEFA       
 13  Portugal          9  UEFA       
 14  Serbia           21  UEFA       
 15  Spain             7  UEFA       
 16  Switzerland      15  UEFA       
 17  Wales            19  UEFA       
└────┴─────────────┴────────┴────────────┘
[17 rows x 3 columns]

# group by columns:
print(sdm.group_by('federation'))

┌───┬────────────┬────────┐
    federation   count 
├───┼────────────┼────────┤
 1  UEFA            13 
 2  CONMEBOL         4 
└───┴────────────┴────────┘
[2 rows x 2 columns]

# or save it for later as csv:
sdm.to_csv('world_cup_22.csv')

# or to sqlite database:
sdm.to_sql('world_cup_22', 'sqlite.db')

# and get it back again as a new model:
sdm_new = SQLDataModel.from_sql('select * from world_cup_22', 'sqlite.db')

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

SQLDataModel-0.1.0.tar.gz (8.6 kB view hashes)

Uploaded Source

Built Distribution

SQLDataModel-0.1.0-py3-none-any.whl (8.6 kB view hashes)

Uploaded Python 3

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