1651970340
Orator
The Orator ORM provides a simple yet beautiful ActiveRecord implementation.
It is inspired by the database part of the Laravel framework, but largely modified to be more pythonic.
The full documentation is available here: http://orator-orm.com/docs
You can install Orator in 2 different ways:
pip install orator
The different dbapi packages are not part of the package dependencies, so you must install them in order to connect to corresponding databases:
psycopg2
PyMySQL
or mysqlclient
sqlite3
module is bundled with Python by defaultAll you need to get you started is the configuration describing your database connections and passing it to a DatabaseManager
instance.
from orator import DatabaseManager, Model
config = {
'mysql': {
'driver': 'mysql',
'host': 'localhost',
'database': 'database',
'user': 'root',
'password': '',
'prefix': ''
}
}
db = DatabaseManager(config)
Model.set_connection_resolver(db)
class User(Model):
pass
Note that we did not tell the ORM which table to use for the User
model. The plural "snake case" name of the class name will be used as the table name unless another name is explicitly specified. In this case, the ORM will assume the User
model stores records in the users
table. You can specify a custom table by defining a __table__
property on your model:
class User(Model):
__table__ = 'my_users'
The ORM will also assume that each table has a primary key column named id
. You can define a __primary_key__
property to override this convention. Likewise, you can define a __connection__
property to override the name of the database connection that should be used when using the model.
Once a model is defined, you are ready to start retrieving and creating records in your table. Note that you will need to place updated_at
and created_at
columns on your table by default. If you do not wish to have these columns automatically maintained, set the __timestamps__
property on your model to False
.
users = User.all()
user = User.find(1)
print(user.name)
users = User.where('votes', '>', 100).take(10).get()
for user in users:
print(user.name)
You can also use the query builder aggregate functions:
count = User.where('votes', '>', 100).count()
If you feel limited by the builder's fluent interface, you can use the where_raw
method:
users = User.where_raw('age > ? and votes = 100', [25]).get()
If you need to process a lot of records, you can use the chunk
method to avoid consuming a lot of RAM:
for users in User.chunk(100):
for user in users:
# ...
You can specify which database connection to use when querying a model by using the on
method:
user = User.on('connection-name').find(1)
If you are using read / write connections, you can force the query to use the "write" connection with the following method:
user = User.on_write_connection().find(1)
When creating a new model, you pass attributes to the model constructor. These attributes are then assigned to the model via mass-assignment. Though convenient, this can be a serious security concern when passing user input into a model, since the user is then free to modify any and all of the model's attributes. For this reason, all models protect against mass-assignment by default.
To get started, set the __fillable__
or __guarded__
properties on your model.
The __fillable__
property specifies which attributes can be mass-assigned.
class User(Model):
__fillable__ = ['first_name', 'last_name', 'email']
The __guarded__
is the inverse and acts as "blacklist".
class User(Model):
__guarded__ = ['id', 'password']
You can also block all attributes from mass-assignment:
__guarded__ = ['*']
To create a new record in the database, simply create a new model instance and call the save
method.
user = User()
user.name = 'John'
user.save()
You can also use the create
method to save a model in a single line, but you will need to specify either the __fillable__
or __guarded__
property on the model since all models are protected against mass-assignment by default.
After saving or creating a new model with auto-incrementing IDs, you can retrieve the ID by accessing the object's id
attribute:
inserted_id = user.id
# Create a new user in the database
user = User.create(name='John')
# Retrieve the user by attributes, or create it if it does not exist
user = User.first_or_create(name='John')
# Retrieve the user by attributes, or instantiate it if it does not exist
user = User.first_or_new(name='John')
user = User.find(1)
user.name = 'Foo'
user.save()
You can also run updates as queries against a set of models:
affected_rows = User.where('votes', '>', 100).update(status=2)
To delete a model, simply call the delete
model:
user = User.find(1)
user.delete()
User.destroy(1)
User.destroy(1, 2, 3)
You can also run a delete query on a set of models:
affected_rows = User.where('votes', '>' 100).delete()
If you want to only update the timestamps on a model, you can use the touch
method:
user.touch()
By default, the ORM will maintain the created_at
and updated_at
columns on your database table automatically. Simply add these timestamp
columns to your table. If you do not wish for the ORM to maintain these columns, just add the __timestamps__
property:
class User(Model):
__timestamps__ = False
If you wish to customize the format of your timestamps (the default is the ISO Format) that will be returned when using the to_dict
or the to_json
methods, you can override the get_date_format
method:
class User(Model):
def get_date_format():
return 'DD-MM-YY'
When building JSON APIs, you may often need to convert your models and relationships to dictionaries or JSON. So, Orator includes methods for doing so. To convert a model and its loaded relationship to a dictionary, you may use the to_dict
method:
user = User.with_('roles').first()
return user.to_dict()
Note that entire collections of models can also be converted to dictionaries:
return User.all().serialize()
To convert a model to JSON, you can use the to_json
method!
return User.find(1).to_json()
The database query builder provides a fluent interface to create and run database queries. It can be used to perform most database operations in your application, and works on all supported database systems.
users = db.table('users').get()
for user in users:
print(user['name'])
for users in db.table('users').chunk(100):
for user in users:
# ...
user = db.table('users').where('name', 'John').first()
print(user['name'])
user = db.table('users').where('name', 'John').pluck('name')
roles = db.table('roles').lists('title')
This method will return a list of role titles. It can return a dictionary if you pass an extra key parameter.
roles = db.table('roles').lists('title', 'name')
users = db.table('users').select('name', 'email').get()
users = db.table('users').distinct().get()
users = db.table('users').select('name as user_name').get()
query = db.table('users').select('name')
users = query.add_select('age').get()
users = db.table('users').where('age', '>', 25).get()
users = db.table('users').where('age', '>', 25).or_where('name', 'John').get()
users = db.table('users').where_between('age', [25, 35]).get()
users = db.table('users').where_not_between('age', [25, 35]).get()
users = db.table('users').where_in('id', [1, 2, 3]).get()
users = db.table('users').where_not_in('id', [1, 2, 3]).get()
users = db.table('users').where_null('updated_at').get()
query = db.table('users').order_by('name', 'desc')
query = query.group_by('count')
query = query.having('count', '>', 100)
users = query.get()
users = db.table('users').skip(10).take(5).get()
users = db.table('users').offset(10).limit(5).get()
The query builder can also be used to write join statements.
db.table('users') \
.join('contacts', 'users.id', '=', 'contacts.user_id') \
.join('orders', 'users.id', '=', 'orders.user_id') \
.select('users.id', 'contacts.phone', 'orders.price') \
.get()
db.table('users').left_join('posts', 'users.id', '=', 'posts.user_id').get()
You can also specify more advance join clauses:
clause = JoinClause('contacts').on('users.id', '=', 'contacts.user_id').or_on(...)
db.table('users').join(clause).get()
If you would like to use a "where" style clause on your joins, you may use the where
and or_where
methods on a join. Instead of comparing two columns, these methods will compare the column against a value:
clause = JoinClause('contacts').on('users.id', '=', 'contacts.user_id').where('contacts.user_id', '>', 5)
db.table('users').join(clause).get()
Sometimes you may need to create more advanced where clauses such as "where exists" or nested parameter groupings. It is pretty easy to do with the Orator query builder
db.table('users') \
.where('name', '=', 'John') \
.or_where(
db.query().where('votes', '>', 100).where('title', '!=', 'admin')
).get()
The query above will produce the following SQL:
SELECT * FROM users WHERE name = 'John' OR (votes > 100 AND title != 'Admin')
db.table('users').where_exists(
db.table('orders').select(db.raw(1)).where_raw('order.user_id = users.id')
)
The query above will produce the following SQL:
SELECT * FROM users
WHERE EXISTS (
SELECT 1 FROM orders WHERE orders.user_id = users.id
)
The query builder also provides a variety of aggregate methods, ` such as count
, max
, min
, avg
, and sum
.
users = db.table('users').count()
price = db.table('orders').max('price')
price = db.table('orders').min('price')
price = db.table('orders').avg('price')
total = db.table('users').sum('votes')
Sometimes you may need to use a raw expression in a query. These expressions will be injected into the query as strings, so be careful not to create any SQL injection points! To create a raw expression, you may use the raw()
method:
db.table('users') \
.select(db.raw('count(*) as user_count, status')) \
.where('status', '!=', 1) \
.group_by('status') \
.get()
db.table('users').insert(email='foo@bar.com', votes=0)
db.table('users').insert({
'email': 'foo@bar.com',
'votes': 0
})
It is important to note that there is two notations available. The reason is quite simple: the dictionary notation, though a little less practical, is here to handle columns names which cannot be passed as keywords arguments.
If the table has an auto-incrementing id, use insert_get_id
to insert a record and retrieve the id:
id = db.table('users').insert_get_id({
'email': 'foo@bar.com',
'votes': 0
})
db.table('users').insert([
{'email': 'foo@bar.com', 'votes': 0},
{'email': 'bar@baz.com', 'votes': 0}
])
db.table('users').where('id', 1).update(votes=1)
db.table('users').where('id', 1).update({'votes': 1})
Like the insert
statement, there is two notations available. The reason is quite simple: the dictionary notation, though a little less practical, is here to handle columns names which cannot be passed as keywords arguments.
db.table('users').increment('votes') # Increment the value by 1
db.table('users').increment('votes', 5) # Increment the value by 5
db.table('users').decrement('votes') # Decrement the value by 1
db.table('users').decrement('votes', 5) # Decrement the value by 5
You can also specify additional columns to update:
db.table('users').increment('votes', 1, name='John')
db.table('users').where('age', '<', 25).delete()
db.table('users').delete()
db.table('users').truncate()
The query builder provides a quick and easy way to "union" two queries:
first = db.table('users').where_null('first_name')
users = db.table('users').where_null('last_name').union(first).get()
The union_all
method is also available.
Sometimes you may wish to use one database connection for SELECT statements, and another for INSERT, UPDATE, and DELETE statements. Orator makes this easy, and the proper connections will always be used whether you use raw queries, the query builder or the actual ORM
Here is an example of how read / write connections should be configured:
config = {
'mysql': {
'read': {
'host': '192.168.1.1'
},
'write': {
'host': '192.168.1.2'
},
'driver': 'mysql',
'database': 'database',
'user': 'root',
'password': '',
'prefix': ''
}
}
Note that two keys have been added to the configuration dictionary: read
and write
. Both of these keys have dictionary values containing a single key: host
. The rest of the database options for the read
and write
connections will be merged from the main mysql
dictionary. So, you only need to place items in the read
and write
dictionaries if you wish to override the values in the main dictionary. So, in this case, 192.168.1.1
will be used as the "read" connection, while 192.168.1.2
will be used as the "write" connection. The database credentials, prefix, character set, and all other options in the main mysql
dictionary will be shared across both connections.
To run a set of operations within a database transaction, you can use the transaction
method which is a context manager:
with db.transaction():
db.table('users').update({votes: 1})
db.table('posts').delete()
Note
Any exception thrown within a transaction block will cause the transaction to be rolled back automatically.
Sometimes you may need to start a transaction yourself:
db.begin_transaction()
You can rollback a transaction with the rollback
method:
db.rollback()
You can also commit a transaction via the commit
method:
db.commit()
By default, all underlying DBAPI connections are set to be in autocommit mode meaning that you don't need to explicitly commit after each operation.
When using multiple connections, you can access them via the connection()
method:
users = db.connection('foo').table('users').get()
You also can access the raw, underlying dbapi connection instance:
db.connection().get_connection()
Sometimes, you may need to reconnect to a given database:
db.reconnect('foo')
If you need to disconnect from the given database, use the disconnect
method:
db.disconnect('foo')
Author: sdispater
Source Code: https://github.com/sdispater/orator
License: MIT License
1651970340
Orator
The Orator ORM provides a simple yet beautiful ActiveRecord implementation.
It is inspired by the database part of the Laravel framework, but largely modified to be more pythonic.
The full documentation is available here: http://orator-orm.com/docs
You can install Orator in 2 different ways:
pip install orator
The different dbapi packages are not part of the package dependencies, so you must install them in order to connect to corresponding databases:
psycopg2
PyMySQL
or mysqlclient
sqlite3
module is bundled with Python by defaultAll you need to get you started is the configuration describing your database connections and passing it to a DatabaseManager
instance.
from orator import DatabaseManager, Model
config = {
'mysql': {
'driver': 'mysql',
'host': 'localhost',
'database': 'database',
'user': 'root',
'password': '',
'prefix': ''
}
}
db = DatabaseManager(config)
Model.set_connection_resolver(db)
class User(Model):
pass
Note that we did not tell the ORM which table to use for the User
model. The plural "snake case" name of the class name will be used as the table name unless another name is explicitly specified. In this case, the ORM will assume the User
model stores records in the users
table. You can specify a custom table by defining a __table__
property on your model:
class User(Model):
__table__ = 'my_users'
The ORM will also assume that each table has a primary key column named id
. You can define a __primary_key__
property to override this convention. Likewise, you can define a __connection__
property to override the name of the database connection that should be used when using the model.
Once a model is defined, you are ready to start retrieving and creating records in your table. Note that you will need to place updated_at
and created_at
columns on your table by default. If you do not wish to have these columns automatically maintained, set the __timestamps__
property on your model to False
.
users = User.all()
user = User.find(1)
print(user.name)
users = User.where('votes', '>', 100).take(10).get()
for user in users:
print(user.name)
You can also use the query builder aggregate functions:
count = User.where('votes', '>', 100).count()
If you feel limited by the builder's fluent interface, you can use the where_raw
method:
users = User.where_raw('age > ? and votes = 100', [25]).get()
If you need to process a lot of records, you can use the chunk
method to avoid consuming a lot of RAM:
for users in User.chunk(100):
for user in users:
# ...
You can specify which database connection to use when querying a model by using the on
method:
user = User.on('connection-name').find(1)
If you are using read / write connections, you can force the query to use the "write" connection with the following method:
user = User.on_write_connection().find(1)
When creating a new model, you pass attributes to the model constructor. These attributes are then assigned to the model via mass-assignment. Though convenient, this can be a serious security concern when passing user input into a model, since the user is then free to modify any and all of the model's attributes. For this reason, all models protect against mass-assignment by default.
To get started, set the __fillable__
or __guarded__
properties on your model.
The __fillable__
property specifies which attributes can be mass-assigned.
class User(Model):
__fillable__ = ['first_name', 'last_name', 'email']
The __guarded__
is the inverse and acts as "blacklist".
class User(Model):
__guarded__ = ['id', 'password']
You can also block all attributes from mass-assignment:
__guarded__ = ['*']
To create a new record in the database, simply create a new model instance and call the save
method.
user = User()
user.name = 'John'
user.save()
You can also use the create
method to save a model in a single line, but you will need to specify either the __fillable__
or __guarded__
property on the model since all models are protected against mass-assignment by default.
After saving or creating a new model with auto-incrementing IDs, you can retrieve the ID by accessing the object's id
attribute:
inserted_id = user.id
# Create a new user in the database
user = User.create(name='John')
# Retrieve the user by attributes, or create it if it does not exist
user = User.first_or_create(name='John')
# Retrieve the user by attributes, or instantiate it if it does not exist
user = User.first_or_new(name='John')
user = User.find(1)
user.name = 'Foo'
user.save()
You can also run updates as queries against a set of models:
affected_rows = User.where('votes', '>', 100).update(status=2)
To delete a model, simply call the delete
model:
user = User.find(1)
user.delete()
User.destroy(1)
User.destroy(1, 2, 3)
You can also run a delete query on a set of models:
affected_rows = User.where('votes', '>' 100).delete()
If you want to only update the timestamps on a model, you can use the touch
method:
user.touch()
By default, the ORM will maintain the created_at
and updated_at
columns on your database table automatically. Simply add these timestamp
columns to your table. If you do not wish for the ORM to maintain these columns, just add the __timestamps__
property:
class User(Model):
__timestamps__ = False
If you wish to customize the format of your timestamps (the default is the ISO Format) that will be returned when using the to_dict
or the to_json
methods, you can override the get_date_format
method:
class User(Model):
def get_date_format():
return 'DD-MM-YY'
When building JSON APIs, you may often need to convert your models and relationships to dictionaries or JSON. So, Orator includes methods for doing so. To convert a model and its loaded relationship to a dictionary, you may use the to_dict
method:
user = User.with_('roles').first()
return user.to_dict()
Note that entire collections of models can also be converted to dictionaries:
return User.all().serialize()
To convert a model to JSON, you can use the to_json
method!
return User.find(1).to_json()
The database query builder provides a fluent interface to create and run database queries. It can be used to perform most database operations in your application, and works on all supported database systems.
users = db.table('users').get()
for user in users:
print(user['name'])
for users in db.table('users').chunk(100):
for user in users:
# ...
user = db.table('users').where('name', 'John').first()
print(user['name'])
user = db.table('users').where('name', 'John').pluck('name')
roles = db.table('roles').lists('title')
This method will return a list of role titles. It can return a dictionary if you pass an extra key parameter.
roles = db.table('roles').lists('title', 'name')
users = db.table('users').select('name', 'email').get()
users = db.table('users').distinct().get()
users = db.table('users').select('name as user_name').get()
query = db.table('users').select('name')
users = query.add_select('age').get()
users = db.table('users').where('age', '>', 25).get()
users = db.table('users').where('age', '>', 25).or_where('name', 'John').get()
users = db.table('users').where_between('age', [25, 35]).get()
users = db.table('users').where_not_between('age', [25, 35]).get()
users = db.table('users').where_in('id', [1, 2, 3]).get()
users = db.table('users').where_not_in('id', [1, 2, 3]).get()
users = db.table('users').where_null('updated_at').get()
query = db.table('users').order_by('name', 'desc')
query = query.group_by('count')
query = query.having('count', '>', 100)
users = query.get()
users = db.table('users').skip(10).take(5).get()
users = db.table('users').offset(10).limit(5).get()
The query builder can also be used to write join statements.
db.table('users') \
.join('contacts', 'users.id', '=', 'contacts.user_id') \
.join('orders', 'users.id', '=', 'orders.user_id') \
.select('users.id', 'contacts.phone', 'orders.price') \
.get()
db.table('users').left_join('posts', 'users.id', '=', 'posts.user_id').get()
You can also specify more advance join clauses:
clause = JoinClause('contacts').on('users.id', '=', 'contacts.user_id').or_on(...)
db.table('users').join(clause).get()
If you would like to use a "where" style clause on your joins, you may use the where
and or_where
methods on a join. Instead of comparing two columns, these methods will compare the column against a value:
clause = JoinClause('contacts').on('users.id', '=', 'contacts.user_id').where('contacts.user_id', '>', 5)
db.table('users').join(clause).get()
Sometimes you may need to create more advanced where clauses such as "where exists" or nested parameter groupings. It is pretty easy to do with the Orator query builder
db.table('users') \
.where('name', '=', 'John') \
.or_where(
db.query().where('votes', '>', 100).where('title', '!=', 'admin')
).get()
The query above will produce the following SQL:
SELECT * FROM users WHERE name = 'John' OR (votes > 100 AND title != 'Admin')
db.table('users').where_exists(
db.table('orders').select(db.raw(1)).where_raw('order.user_id = users.id')
)
The query above will produce the following SQL:
SELECT * FROM users
WHERE EXISTS (
SELECT 1 FROM orders WHERE orders.user_id = users.id
)
The query builder also provides a variety of aggregate methods, ` such as count
, max
, min
, avg
, and sum
.
users = db.table('users').count()
price = db.table('orders').max('price')
price = db.table('orders').min('price')
price = db.table('orders').avg('price')
total = db.table('users').sum('votes')
Sometimes you may need to use a raw expression in a query. These expressions will be injected into the query as strings, so be careful not to create any SQL injection points! To create a raw expression, you may use the raw()
method:
db.table('users') \
.select(db.raw('count(*) as user_count, status')) \
.where('status', '!=', 1) \
.group_by('status') \
.get()
db.table('users').insert(email='foo@bar.com', votes=0)
db.table('users').insert({
'email': 'foo@bar.com',
'votes': 0
})
It is important to note that there is two notations available. The reason is quite simple: the dictionary notation, though a little less practical, is here to handle columns names which cannot be passed as keywords arguments.
If the table has an auto-incrementing id, use insert_get_id
to insert a record and retrieve the id:
id = db.table('users').insert_get_id({
'email': 'foo@bar.com',
'votes': 0
})
db.table('users').insert([
{'email': 'foo@bar.com', 'votes': 0},
{'email': 'bar@baz.com', 'votes': 0}
])
db.table('users').where('id', 1).update(votes=1)
db.table('users').where('id', 1).update({'votes': 1})
Like the insert
statement, there is two notations available. The reason is quite simple: the dictionary notation, though a little less practical, is here to handle columns names which cannot be passed as keywords arguments.
db.table('users').increment('votes') # Increment the value by 1
db.table('users').increment('votes', 5) # Increment the value by 5
db.table('users').decrement('votes') # Decrement the value by 1
db.table('users').decrement('votes', 5) # Decrement the value by 5
You can also specify additional columns to update:
db.table('users').increment('votes', 1, name='John')
db.table('users').where('age', '<', 25).delete()
db.table('users').delete()
db.table('users').truncate()
The query builder provides a quick and easy way to "union" two queries:
first = db.table('users').where_null('first_name')
users = db.table('users').where_null('last_name').union(first).get()
The union_all
method is also available.
Sometimes you may wish to use one database connection for SELECT statements, and another for INSERT, UPDATE, and DELETE statements. Orator makes this easy, and the proper connections will always be used whether you use raw queries, the query builder or the actual ORM
Here is an example of how read / write connections should be configured:
config = {
'mysql': {
'read': {
'host': '192.168.1.1'
},
'write': {
'host': '192.168.1.2'
},
'driver': 'mysql',
'database': 'database',
'user': 'root',
'password': '',
'prefix': ''
}
}
Note that two keys have been added to the configuration dictionary: read
and write
. Both of these keys have dictionary values containing a single key: host
. The rest of the database options for the read
and write
connections will be merged from the main mysql
dictionary. So, you only need to place items in the read
and write
dictionaries if you wish to override the values in the main dictionary. So, in this case, 192.168.1.1
will be used as the "read" connection, while 192.168.1.2
will be used as the "write" connection. The database credentials, prefix, character set, and all other options in the main mysql
dictionary will be shared across both connections.
To run a set of operations within a database transaction, you can use the transaction
method which is a context manager:
with db.transaction():
db.table('users').update({votes: 1})
db.table('posts').delete()
Note
Any exception thrown within a transaction block will cause the transaction to be rolled back automatically.
Sometimes you may need to start a transaction yourself:
db.begin_transaction()
You can rollback a transaction with the rollback
method:
db.rollback()
You can also commit a transaction via the commit
method:
db.commit()
By default, all underlying DBAPI connections are set to be in autocommit mode meaning that you don't need to explicitly commit after each operation.
When using multiple connections, you can access them via the connection()
method:
users = db.connection('foo').table('users').get()
You also can access the raw, underlying dbapi connection instance:
db.connection().get_connection()
Sometimes, you may need to reconnect to a given database:
db.reconnect('foo')
If you need to disconnect from the given database, use the disconnect
method:
db.disconnect('foo')
Author: sdispater
Source Code: https://github.com/sdispater/orator
License: MIT License
1592298751
Do you want to build a superior beauty salon mobile app for your business? Then AppClues Infotech is a professional mobile app development company that works with a hair salon, Spa, and other businesses in the beauty industry.
Being the premier beauty salon mobile app development company we render quality solutions by making use of innovative thoughts. Our accomplished techies are adept at designing the feasible solutions that are affordable and cost-effective.
For more info:
Call: +1-978-309-9910
Email: info@appcluesinfotech.com
#how to build a mobile app for beauty salon #beauty salon app development company #best beauty salon app development company #top beauty salon app development company #create a beauty salon mobile app
1608807297
Who doesn’t love to groom themselves? Almost all would love to. Now, people can avail of the beauty services right at the confines of their homes. As everything has become available to our doorsteps, why not beauty services? Yes, the beautician on-demand services have become one of the favorite on-demand services among users. If you are keen on knowing more about the beauty services app, here you go!
Let us first go through the working pattern of the on-demand beauty services app.
Step 1- Users will download your app and fill out the necessary information to access the app.
Step 2- Once users complete the first step of registration, users will land on the homepage of your app.
Step 3- The app has a list of beauty service providers with which users can choose their favorite beauticians.
Step 4- Users will request for the service and the service provider will confirm the request based on their availability.
Step 5- Once the service provider confirms the request, users will make the payment.
Step 6- The app generates the estimated time of arrival once the user’s request is confirmed.
Step 7- The service provider will reach the user’s location and will complete the service.
Among the several on-demand beauty apps, the Uber like app for beauty is gaining prominence among users with its ravishing features. Let us know the features that give an extraordinary user experience.
Schedule appointments- Users can avail of the beauty services at their convenient date by scheduling the appointment.
Rate estimator- Users can get to know the rate of their beauty services once they enter the type of service and location in the app. The app will generate the fare of the service.
Availability toggle- The service providers can provide services to users according to their convenience. The service provider can indicate whether he/she is available to take the service by moving the toggle button accordingly.
Conclusion
Summing up, the on-demand beauty app development will be the fortune cookie of your business as you can earn revenue and users coherently.
#uber for beauty service app #on-demand beauty app development #on-demand beauty service app development #on-demand beauty service app
1657396680
Simple ORM built on leveldb/levelup.
Installation
This module is installed via npm:
$ npm install level-orm
You extend the base class to give you ORM getters and setters.
NB: You pass in a 'container' object to the Model constructor which must have a leveldb instance on the db
property of the object. This allows you to share state between models by passing in the same container object for each sublevel model object that you create.
var level = require('level');
var db = level('/tmp/db', { valueEncoding: 'json' });
var Model = require('level-orm');
function Users(db) {
// users is the sublevel name to user
// handle is the primary key to user for insertion
Models.call(this, { db: db }, 'users', 'handle');
}
util.inherits(Users, Models);
var users = new Users(db);
// save to database
users.save({ handle: 'eugeneware', name: 'Eugene', email: 'eugene@noblesamurai.com' },
function (err, id) {
// id will be the primary key
});
// retrieve from database
users.get('eugeneware', function (err, user) { });
// delete from database
users.del('eugeneware');
// stream from database
users.createReadStream({start: 'a', end: 'c'}).pipe(...);
If you use bytewise you can have compound keys, like so:
var level = require('level');
var bytewise = require('bytewise/hex');
var db = level('/tmp/db', { keyEncoding: bytewise, valueEncoding: 'json' });
var Model = require('level-orm');
function Feed(db) {
// compound key of 'user' and 'id'
Models.call(this, { db: db }, 'feed', ['user', 'id']);
}
util.inherits(Feed, Models);
var feed = new Feed(db);
feed.save({ user: 'eugeneware', id: 123, message: 'Test' }, cb);
NB: That in leveldb the default encoding is 'utf8' where keys will sort lexicographically. Thus 10
will sort before 2
unless you use an encoding such as bytewise
to change this behaviour.
Implement the keyfn
function on the extended model to automatically generate keys when none is found in the model to be saved:
var level = require('level');
var bytewise = require('bytewise/hex');
// we're just going to use a unique timestamp for our keys
var timestamp = require('monotonic-timestamp');
var db = level('/tmp/db', { keyEncoding: bytewise, valueEncoding: 'json' });
function Messages(db) {
Models.call(this, { db: db }, 'messages', 'id');
}
util.inherits(Messages, Models);
// set the function to generate ids
Messages.prototype.keyfn = timestamp;
var messages = new Messages(db);
messages.save({ message: 'My message' }, function (err, id) {
// id will contain the auto-generated ID
});
var level = require('level');
var bytewise = require('bytewise/hex');
var timestamp = require('monotonic-timestamp');
// Container class
function LevelMicroBlog(dbPath) {
this.db = sublevel(level(dbPath, { keyEncoding: bytewise, valueEncoding: 'json' }));
this.Users = new Users(this);
this.Messages = new Messages(this);
}
LevelMicroBlog.prototype.close = function(cb) {
if (this.db) return this.db.close(cb);
this.db = null;
cb(null);
}
// Users sublevel model
function Users(container) {
Models.call(this, container, 'users', 'handle');
}
util.inherits(Users, Models);
// Messages sublevel model
function Messages(container) {
Models.call(this, container, 'messages', 'id');
}
util.inherits(Messages, Models);
Messages.prototype.keyfn = timestamp;
// instantiate a new container class
var mblog = new LevelMicroBlog('/tmp/db');
mblog.Users.save({ 'handle': 'EugeneWare', name: 'Eugene Ware'}, ...);
mblog.Messages.save({ message: 'A new message' }, ...);
The original level-sublevel
(https://github.com/dominictarr/level-sublevel) didn't support binary encodings, but as of 0.6 of sublevel
, you can use native bytewise encoding of sublevels. If you want this, then require level-orm/bytewise
and the underlying sublevel will use bytewise to encode sublevels:
var Model = require('level-orm/bytewise');
// extend as usual
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY EUGENE WARE ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DEOXXA DEVELOPMENT BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Original article source at: https://github.com/eugeneware/level-orm
1624402800
The Beautiful Soup module is used for web scraping in Python. Learn how to use the Beautiful Soup and Requests modules in this tutorial. After watching, you will be able to start scraping the web on your own.
📺 The video in this post was made by freeCodeCamp.org
The origin of the article: https://www.youtube.com/watch?v=87Gx3U0BDlo&list=PLWKjhJtqVAbnqBxcdjVGgT3uVR10bzTEB&index=12
🔥 If you’re a beginner. I believe the article below will be useful to you ☞ What You Should Know Before Investing in Cryptocurrency - For Beginner
⭐ ⭐ ⭐The project is of interest to the community. Join to Get free ‘GEEK coin’ (GEEKCASH coin)!
☞ **-----CLICK HERE-----**⭐ ⭐ ⭐
Thanks for visiting and watching! Please don’t forget to leave a like, comment and share!
#web scraping #python #beautiful soup #beautiful soup tutorial #web scraping in python #beautiful soup tutorial - web scraping in python