Skip to main content

No project description provided

Project description

CSV RM

DO NOT USE ON PRODUCTION

Object relational mapping from csv file. This module will load csv to memory and treat it like Object. This module main purpose is to ease up csv usage in small application, mainly in use in sandboxing. It's highly ineficient and doesn't support multiple instance.

Features

CSV RM provide basic orm utility such as :

  • Load csv to object
  • Create new record
  • Update existing record
  • Delete records
  • Search records

What not supported yet:

  • Transaction
  • Concurrent usage

Installation

Just install it directly using pip. No dependecies needed.

pip install csvrm

Or you can just copy entire source code.

Usage

  1. Define model structure Defining new model by inheriting Model class. Put csv file location inside _filename variable. Define each fields you want to extract by specifiy it as object.
from csvrm import models, fields

class Person(models.Model):
    _filename = '[filepath]'

    id = fields.Integer()
    name = fields.String()
  1. Create records
p = Person(load = true)
p.create({
    'id': 1,
    'name': 'person name'
})
p.save()
  1. Seach records
p = Person(load = true)
result = p.search(lambda x: x.name == 'person name')
for res in result:
    print(res.name)
  1. Update records Updating record can be done using either update methods or directly change properties
p = Person(load = true)

result = p.search(lambda x: x.name == 'person name')
for res in result:
    res.name = 'new person name'
p.save()

# OR
p.update(
    domain=(lambda x: x.id == 10),
    values= {'name': 'new person name'}
)
p.save()
  1. Delete records
p = Person(load = true)
p.unlink(
    domain=(lambda x: x.id == 10)
)
p.save()

FOR FULL DETAIL, READ THE CODE

Contributing

Fell free to port or contribute this project

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

csvrm-0.2.2.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

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

csvrm-0.2.2-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file csvrm-0.2.2.tar.gz.

File metadata

  • Download URL: csvrm-0.2.2.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.0

File hashes

Hashes for csvrm-0.2.2.tar.gz
Algorithm Hash digest
SHA256 d955e3b1c7de8b1fe2de286a7b7bd8d2c1d38911ff4c6e0e124d8ec62a020fe9
MD5 d9f590f5a1226175f1e1a493519f3036
BLAKE2b-256 e872c7a1248d22d8f165c4b4adb0a4b1889d592b336e1e1c7dec5ef4d4bdc75b

See more details on using hashes here.

File details

Details for the file csvrm-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: csvrm-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 6.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.0

File hashes

Hashes for csvrm-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 18cff1aab650bf290fff4863f7eb19a1ed491bb02cff22dd5143b63e8933ea84
MD5 68074a27165a118a939517d2a9cdd4d0
BLAKE2b-256 fd94a4289df4ad918b1bd2559fed2665161bcdb4057219b866bbb6726fe7ff3e

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