Skip to content

Commit 59eaba3

Browse files
authored
Merge pull request #323 from fabiansinz/master
Add `size_on_disk` property for schema
2 parents 05badcd + 1004237 commit 59eaba3

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

datajoint/schema.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,15 @@ def __repr__(self):
7676
database=self.database,
7777
context=self.context['__name__'] if '__name__' in self.context else "__")
7878

79+
@property
80+
def size_on_disk(self):
81+
"""
82+
:return: size of the database in bytes
83+
"""
84+
return float(self.connection.query(
85+
"""SELECT Sum(data_length + index_length) FROM information_schema.tables WHERE table_schema='{}';""".format(
86+
self.database)).fetchone()[0])
87+
7988
def spawn_missing_classes(self):
8089
"""
8190
Creates the appropriate python user relation classes from tables in the database and places them

0 commit comments

Comments
 (0)