Skip to content

Commit

Permalink
Initial commit of 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
twheys committed Jan 19, 2018
1 parent 9ac6b3a commit f54bcee
Show file tree
Hide file tree
Showing 77 changed files with 3,218 additions and 10,355 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
language: python

python:
- "2.7"
- "3.3"
- "3.4"
- "3.5"
Expand Down
15 changes: 13 additions & 2 deletions fireant/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
# coding: utf-8
__version__ = '{major}.{minor}.{patch}'.format(major=0, minor=19, patch=3)
# noinspection PyUnresolvedReferences
from .database import *
# noinspection PyUnresolvedReferences
from .slicer import *
# noinspection PyUnresolvedReferences
from .slicer.widgets import (
DataTablesJS,
HighCharts,
Matplotlib,
Pandas,
)

__version__ = '{major}.{minor}.{patch}'.format(major=1, minor=0, patch=0)
17 changes: 0 additions & 17 deletions fireant/dashboards/__init__.py

This file was deleted.

76 changes: 0 additions & 76 deletions fireant/dashboards/managers.py

This file was deleted.

117 changes: 0 additions & 117 deletions fireant/dashboards/schemas.py

This file was deleted.

9 changes: 3 additions & 6 deletions fireant/database/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# coding: utf-8

from .database import Database
from .base import Database
from .mysql import MySQLDatabase
from .redshift import RedshiftDatabase
from .postgresql import PostgreSQLDatabase
from .vertica import (Vertica,
VerticaDatabase)
from .redshift import RedshiftDatabase
from .vertica import VerticaDatabase
12 changes: 8 additions & 4 deletions fireant/database/database.py → fireant/database/base.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
# coding: utf-8

import pandas as pd

from pypika import Query
from pypika import (
Query,
terms,
)


class Database(object):
"""
WRITEME
"""
# The pypika query class to use for constructing queries
query_cls = Query

Expand All @@ -15,7 +19,7 @@ def connect(self):
def trunc_date(self, field, interval):
raise NotImplementedError

def date_add(self, date_part, interval, field):
def date_add(self, field: terms.Term, date_part: str, interval: int):
""" Database specific function for adding or subtracting dates """
raise NotImplementedError

Expand Down
17 changes: 7 additions & 10 deletions fireant/database/mysql.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# coding: utf-8
import pandas as pd

from pypika import (
Dialects,
MySQLQuery,
terms,
)

from fireant.database import Database
from .base import Database


class Trunc(terms.Function):
Expand Down Expand Up @@ -51,12 +50,10 @@ def __init__(self, database=None, host='localhost', port=3306,
def connect(self):
import pymysql

return pymysql.connect(
host=self.host, port=self.port, db=self.database,
user=self.user, password=self.password,
charset=self.charset,
cursorclass=pymysql.cursors.Cursor,
)
return pymysql.connect(host=self.host, port=self.port, db=self.database,
user=self.user, password=self.password,
charset=self.charset,
cursorclass=pymysql.cursors.Cursor)

def fetch(self, query):
with self.connect().cursor() as cursor:
Expand All @@ -69,7 +66,7 @@ def fetch_dataframe(self, query):
def trunc_date(self, field, interval):
return Trunc(field, interval)

def date_add(self, date_part, interval, field):
def date_add(self, field, date_part, interval):
# adding an extra 's' as MySQL's interval doesn't work with 'year', 'week' etc, it expects a plural
interval_term = terms.Interval(**{'{}s'.format(str(date_part)): interval, 'dialect': Dialects.MYSQL})
return DateAdd(field, interval_term)
13 changes: 5 additions & 8 deletions fireant/database/postgresql.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# coding: utf-8
import pandas as pd

from pypika import (
PostgreSQLQuery,
functions as fn,
terms,
)

from fireant.database import Database
from .base import Database


class Trunc(terms.Function):
Expand Down Expand Up @@ -40,10 +39,8 @@ def __init__(self, database=None, host='localhost', port=5432,
def connect(self):
import psycopg2

return psycopg2.connect(
host=self.host, port=self.port, dbname=self.database,
user=self.user, password=self.password,
)
return psycopg2.connect(host=self.host, port=self.port, dbname=self.database,
user=self.user, password=self.password)

def fetch(self, query):
with self.connect().cursor() as cursor:
Expand All @@ -56,5 +53,5 @@ def fetch_dataframe(self, query):
def trunc_date(self, field, interval):
return Trunc(field, interval)

def date_add(self, date_part, interval, field):
def date_add(self, field, date_part, interval):
return fn.DateAdd(date_part, interval, field)
5 changes: 1 addition & 4 deletions fireant/database/redshift.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# coding: utf-8
from pypika import (
RedshiftQuery,
)
from pypika import RedshiftQuery

from .postgresql import PostgreSQLDatabase

Expand Down
Loading

0 comments on commit f54bcee

Please sign in to comment.