Releases: CrispenGari/dataloom-py
v2.4.2
===
Dataloom 2.4.2
Release Notes - dataloom
We have release the new dataloom Version 2.4.2 (2024-04-11)
Changes
- updated documentation
- documentation available on Read the Docs.
What's Changed
- Rtd by @CrispenGari in #14
- changelogs by @CrispenGari in #15
Full Changelog: 2.4.1...v2.4.2
2.4.1
===
Dataloom 2.4.1
Release Notes - dataloom
We have release the new dataloom Version 2.4.1 (2024-03-02)
Changes
- Updated documentation.
What's Changed
- Update README.md by @CrispenGari in #11
- Update pyproject.toml by @CrispenGari in #12
- Update Changelog.md by @CrispenGari in #13
Full Changelog: v2.4.0...2.4.1
v2.4.0
===
Dataloom 2.4.0
Release Notes - dataloom
We have release the new dataloom Version 2.4.0 (2024-02-27)
Features
-
syncandconnect_and_syncfunction can now take in a collection ofModelor a singleModelinstance. -
Updated documentation.
-
Fixing
ForeignKeyColumnbugs. -
Adding the
aliasas an argument toIncludeclass so that developers can flexibly use their own alias for eager model inclusion rather than lettingdataloomdecide for them. -
Adding the
junction_tableas an argument to theIncludeso that we can use this table as a reference forN-Nassociations. -
Introducing self relations
- now you can define self relations in
dataloom
class Employee(Model): __tablename__: TableColumn = TableColumn(name="employees") id = PrimaryKeyColumn(type="int", auto_increment=True) name = Column(type="text", nullable=False, default="Bob") supervisorId = ForeignKeyColumn( "Employee", maps_to="1-1", type="int", required=False )
- You can also do eager self relations queries
emp_and_sup = mysql_loom.find_by_pk( instance=Employee, pk=2, select=["id", "name", "supervisorId"], include=Include( model=Employee, has="one", select=["id", "name"], alias="supervisor", ), ) print(emp_and_sup) # ? = {'id': 2, 'name': 'Michael Johnson', 'supervisorId': 1, 'supervisor': {'id': 1, 'name': 'John Doe'}}
- now you can define self relations in
-
Introducing
N-Nrelationship- with this version of
dataloomn-nrelationships are now available. However you will need to define a reference table manual. We recommend you to follow our documentation to get the best out of it.
class Course(Model): __tablename__: TableColumn = TableColumn(name="courses") id = PrimaryKeyColumn(type="int", auto_increment=True) name = Column(type="text", nullable=False, default="Bob") class Student(Model): __tablename__: TableColumn = TableColumn(name="students") id = PrimaryKeyColumn(type="int", auto_increment=True) name = Column(type="text", nullable=False, default="Bob") class StudentCourses(Model): __tablename__: TableColumn = TableColumn(name="students_courses") studentId = ForeignKeyColumn(table=Student, type="int") courseId = ForeignKeyColumn(table=Course, type="int")
- you can do
eagerdata fetching in this type of relationship, however you need to specify thejunction_table. Here is an example:
english = mysql_loom.find_by_pk( Course, pk=engId, select=["id", "name"], include=Include(model=Student, junction_table=StudentCourses, has="many"), )
- with this version of
What's Changed
- Relations by @CrispenGari in #10
Full Changelog: v2.3.0...v2.4.0
v2.3.0
===
Dataloom 2.3.0
Release Notes - dataloom
We have release the new dataloom Version 2.3.0 (2024-02-26)
Features
- updated documentation.
- Query Builder in executing queries and SQL Scripts.
qb = loom.getQueryBuilder()
res = qb.run("select id from posts;", fetchall=True)
print(res)We can use the query builder to execute the SQL as follows:
with open("qb.sql", "r") as reader:
sql = reader.read()
res = qb.run(
sql,
fetchall=True,
is_script=True,
)
print(res)👍 Pro Tip: Executing a script using query builder does not return a result. The result value is always
None.
What's Changed
- query builder and the doccumentation by @CrispenGari in #9
Full Changelog: v2.2.0...v2.3.0
v2.2.0
===
Dataloom 2.2.0
Release Notes - dataloom
We have release the new dataloom Version 2.2.0 (2024-02-25)
Features
- updated documentation.
- Added operators
BETWEENandNOTin filters now ypu can use them.
post = loom.find_one(
Post,
filters=Filter(
column="id",
operator="between",
value=[1, 7],
),
select=["id"],
)
post = loom.find_one(
Post,
filters=Filter(
column="id",
operator="not",
value=3,
),
select=["id"],
)Note that the
betweenoperator works on value ranges that are numbers.
- Distinct row selection has been added for the method
find_all()andfind_many()
post = loom.find_many(
Post,
filters=Filter(
column="id",
operator="between",
value=[1, 7],
),
select=["completed"],
distinct=True,
)
post = loom.find_all(
Post,
select=["completed"],
distinct=True,
)The result will return the
distinctrows of data based on the completed value.
- added utility functions
sum,avg,min,maxandcountto the loom object.count = loom.count( instance=Post, filters=Filter( column="id", operator="between", value=[1, 7], ), column="id", )
- Updated logger colors and formatting.
What's Changed
- Utilities by @CrispenGari in #8
Full Changelog: v2.1.1...v2.2.0
v2.1.1
===
Dataloom 2.1.1
Release Notes - dataloom
We have release the new dataloom Version 2.1.0 (2024-02-24)
Features
- updated documentation.
Full Changelog: v2.1.0...v2.1.1
v2.1.0
===
Dataloom 2.1.0
Release Notes - dataloom
We have release the new dataloom Version 2.1.0 (2024-02-24)
Features
-
Connecting to databases using connection
urifor all the supported dialects# postgress pg_loom = Loom( dialect="postgres", connection_uri = "postgressql://root:root@localhost:5432/hi", # ... ) # mysql mysql_loom = Loom( dialect="mysql", connection_uri = "mysql://root:root@localhost:3306/hi", # ... ) # sqlite sqlite_loom = Loom( dialect="sqlite", connection_uri = "sqlite:///hi.db", # ... )
-
updated documentation.
-
enable table alterations as an option of
syncandconnect_and_syncfunction.conn, tables = pg_loom.connect_and_sync([Profile, User], alter=True)
🥇 We recommend you to use
droporforceif you are going to change or modifyforeignandprimarykeys. This is because setting the optionalterdoe not have an effect onprimarykey columns.
v2.0.0
===
Dataloom 2.0.0
Release Notes - dataloom
We have release the new dataloom Version 2.0.0 (2024-02-21)
Features
-
Renaming the class
DataloomtoLoom.from dataloom import Loom
-
Eager data fetching in relationships
- Now you can fetch your child relationship together in your query
user = mysql_loom.find_one( instance=User, filters=[Filter(column="id", value=userId)], include=[Include(model=Profile, select=["id", "avatar"], has="one")], ) print(user)
- You can apply limits, offsets, filters and orders to your child associations during queries
post = mysql_loom.find_one( instance=Post, filters=[Filter(column="userId", value=userId)], select=["title", "id"], include=[ Include( model=User, select=["id", "username"], has="one", include=[Include(model=Profile, select=["avatar", "id"], has="one")], ), Include( model=Category, select=["id", "type"], has="many", order=[Order(column="id", order="DESC")], limit=2, ), ], )
-
Now
return_dicthas bee removed as an option indataloomin the query functions likefind_by_pk,find_one,find_manyandfind_allnow works starting from this version. If you enjoy working with python objects you have to maneuver them manually using experimental features.from dataloom.decorators import initialize @initialize(repr=True, to_dict=True, init=True, repr_identifier="id") class Profile(Model): __tablename__: Optional[TableColumn] = TableColumn(name="profiles") id = PrimaryKeyColumn(type="int", auto_increment=True) avatar = Column(type="text", nullable=False) userId = ForeignKeyColumn( User, maps_to="1-1", type="int", required=True, onDelete="CASCADE", onUpdate="CASCADE", ) # now you can do this profile = mysql_loom.find_many( instance=Profile, ) print([Profile(**p) for p in profile]) # ? = [<Profile:id=1>] print([Profile(**p) for p in profile][0].id) # ? = 1
- These are
experimentaldecorators they are little bit slow and they work perfect in a single instance, you can not nest relationships on them. - You can use them if you know how your data is structured and also if you know how to manipulate dictionaries
- These are
-
Deprecated
to the use ofjoin_next_filter_withjoin_next_with -
Values that was required as
liste.g,select,includeetc can now be passed as a single value.- Before
res = mysql_loom.find_by_pk(Profile, pk=profileId, select={"id", "avatar"}) # invalid res = mysql_loom.find_by_pk(Profile, pk=profileId, select=("id", "avatar")) # invalid res = mysql_loom.find_by_pk(Profile, pk=profileId, select="id") # invalid res = mysql_loom.find_by_pk(Profile, pk=profileId, select=["id"]) # valid
- Now
res = mysql_loom.find_by_pk(Profile, pk=profileId, select={"id", "avatar"}) # valid res = mysql_loom.find_by_pk(Profile, pk=profileId, select=("id", "avatar")) # valid res = mysql_loom.find_by_pk(Profile, pk=profileId, select="id") # valid res = mysql_loom.find_by_pk(Profile, pk=profileId, select=["id"]) # valid
-
Updated the documentation.
-
Grouping data in queries will also be part of this release, using the class
GroupandHaving.
posts = pg_loom.find_many(
Post,
select="id",
filters=Filter(column="id", operator="gt", value=1),
group=Group(
column="id",
function="MAX",
having=Having(column="id", operator="in", value=(2, 3, 4)),
return_aggregation_column=True,
),
)v1.0.2
We have release the new dataloom Version 1.0.2 (2024-02-12)
Changes
We have updated the documentation so that it can look more colorful.
v1.0.1
Release Notes - dataloom
We have made minor changes for this version of dataloom. The dataloom version 1.0.1 released on (2024-02-12) comes up with the following new features.
New Features
- Docstring: Now the functions and classes have a beautiful docstring that helps ypu with some examples and references in the editor.
- SQL Loggers: The SQL Loggers can now log
timestampsnot the log index especially for theconsolelogger.
Enhancements
- None
Bug Fixes
- log_index: There was a bug with
log_indexthat was breaking the entire sofware that has been fixed.