Example #1
0
 def test_02_00(self):
     dbsession = createdbsession('sqlite:///testdatabase.db',
                                 sqlecho=False,
                                 cleardown=True)
     with open('testlocations.csv', mode='r') as fp:
         csvreader = csv.reader(fp)
         for data in csvreader:
             add_location = Locations(locationid=data[0],
                                      name=data[1],
                                      description=data[2],
                                      sublocation=data[3])
             dbsession.add(add_location)
             print data
     with open('testmedia.csv', mode='r') as fp:
         csvreader = csv.reader(fp)
         for data in csvreader:
             add_media = Media(mediaid=data[0],
                               mediatype=data[1],
                               title=data[2],
                               description=data[3],
                               url=data[4],
                               barcode=data[5],
                               locationid=data[6])
             dbsession.add(add_media)
             print data
     dbsession.commit()
Example #2
0
 def test_01_database(self):
     # Set up a session
     testsession = createdbsession('sqlite:///testdatabase.db',
                                   sqlecho=False,
                                   cleardown=True)
     testsession.close()
     os.unlink('testdatabase.db')
Example #3
0
 def test_02_00(self):
     dbsession = createdbsession('sqlite:///testdatabase.db', sqlecho=False, cleardown=True)
     with open('testlocations.csv', mode='r') as fp:
         csvreader = csv.reader(fp)
         for data in csvreader:
             add_location = Locations(locationid = data[0], name = data[1], description = data[2],
                                      sublocation = data[3])
             dbsession.add(add_location)
             print data
     with open('testmedia.csv', mode='r') as fp:
         csvreader = csv.reader(fp)
         for data in csvreader:
             add_media = Media(mediaid = data[0],
                               mediatype = data[1],
                               title = data[2],
                               description = data[3],
                               url = data[4],
                               barcode = data[5],
                               locationid = data[6])
             dbsession.add(add_media)
             print data
     dbsession.commit()
Example #4
0
from flask import Flask, render_template, request, send_file, flash, redirect, url_for
from models import Locations, Media
from forms import BasicForm, MediaForm, LocationsForm
from sqlalchemy.orm.exc import NoResultFound
from sqlalchemy import func

app = Flask(__name__)
app.config.from_pyfile('flaskcfg.cfg')
app.config.from_envvar('APP_SETTINGS', silent=True)

# Read configuration
config = appconfig('mediadb.cfg')

# Connect to database
session = createdbsession(config.get('Database', 'Name'),
                          sqlecho=False,
                          cleardown=False)


def chooseobject(option=None, *args):
    if option == 'media':
        obj = MediaObject(session, args[0])
    elif option == 'location':
        obj = LocationObject(session, Locations)
    else:
        obj = None
    return obj


def createstaticquery(querymodel):
    queryobj = session.query(querymodel). \
Example #5
0
from forms import BasicForm, MediaForm, LocationsForm
from sqlalchemy.orm.exc import NoResultFound
from sqlalchemy import func


app = Flask(__name__)
app.config.from_pyfile('flaskcfg.cfg')
app.config.from_envvar('APP_SETTINGS', silent=True)


# Read configuration
config = appconfig('mediadb.cfg')

# Connect to database
session = createdbsession(config.get('Database', 'Name'),
                          sqlecho=False,
                          cleardown=False)


def chooseobject(option=None, *args):
    if option == 'media':
        obj = MediaObject(session, args[0])
    elif option == 'location':
        obj = LocationObject(session, Locations)
    else:
        obj = None
    return obj


def createstaticquery(querymodel):
    queryobj = session.query(querymodel). \
Example #6
0
 def test_01_database(self):
     # Set up a session
     testsession = createdbsession('sqlite:///testdatabase.db', sqlecho=False, cleardown=True)
     testsession.close()
     os.unlink('testdatabase.db')