Skip to content

Commit e846611

Browse files
committed
Add examples to README
1 parent 0da9c87 commit e846611

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

README.rst

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,37 @@ source file:
7575
7676
pixel_x, pixel_y = get_pixel_coords()
7777
78+
factdb
79+
------
80+
81+
This module contains ``peewee`` ``Models`` for our ``factdata`` MySQL database.
82+
These were automatically created by ``peewee`` and provide means to query this database in python without writing raw sql queries.
83+
84+
For example, to get the total number of runs take by FACT you can do:
85+
86+
.. code:: python
87+
88+
from fact.factdb import connect_database, RunInfo
89+
90+
connect_database() # this uses the credentials module if no config is given
91+
92+
num_runs = RunInfo.select().count()
93+
94+
A few convenience functions are already implemented.
95+
To get a ``pandas.DataFrame`` containing the observation time per source and runtype, you can do:
96+
97+
98+
.. code:: python
99+
100+
from fact.factdb import connect_database, get_ontime_per_source_and_runtype
101+
102+
connect_database()
103+
104+
num_runs = RunInfo.select().count()
105+
print(get_ontime_by_source_and_runtype())
106+
107+
108+
78109
auxservices
79110
-----------
80111

0 commit comments

Comments
 (0)