Effortless Usage
You can get started with Effortless in just a few simple steps. If you're looking for more complexity, check the other tiers of usage!
Get set up
You'll need to
install Effortless if you
haven't yet. After that, start up Python in a new terminal or
command-line.
Type this in and hit enter:
Need help?
Importing Effortless
After you've installed Effortless and started Python, you'll
need to import the module to access a database.
Run this:
This will automatically start a database db
which
you can now use with db.action()
where action is
what you want to do.
Adding Entries to the Database
Use add(data)
to insert a new entry into the
database. Let's add some data to work with:
This adds two entries to the database: Alice, who is 30 years old, and Bob, who is 25.
Retrieving All Entries
get_all()
returns all entries in the database:
This will return:
[{'name': 'Alice', 'age': 30}, {'name': 'Bob', 'age': 25}]
You can see both Alice and Bob in the list.
Filtering Entries
Use filter(requirement)
with a
Field
requirement to find specific entries. A
Field
checks for something to be in an entry, and
then checks any additional conditions you've added; in the
example below, we check for entries which both
have a name and who's name is equal to Alice.
This will return only Alice's data and not Bob's.
Got it down effortlessly? Try the Basic Usage!