Python settings.DATABASE Examples
The following are 6
code examples of settings.DATABASE().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
settings
, or try the search function
.
Example #1
Source File: conftest.py From mattermost-poll with GNU General Public License v3.0 | 5 votes |
def clear_database(): assert settings.TEST_SETTINGS if os.path.exists(settings.DATABASE): os.remove(settings.DATABASE)
Example #2
Source File: poll.py From mattermost-poll with GNU General Public License v3.0 | 5 votes |
def create(cls, creator_id, message, locale='en', vote_options=[], secret=False, public=False, max_votes=1, bars=False): """Creates a new poll without any votes. Empty vote_options will be replaced by ['Yes', 'No']. """ con = sqlite3.connect(settings.DATABASE) init_database(con) cur = con.cursor() if not vote_options: with force_locale(locale): vote_options = [tr('Yes'), tr('No')] # clamp to 1 to len(vote_options) max_votes = max(1, min(max_votes, len(vote_options))) cur.execute("""INSERT INTO Polls (creator, message, locale, finished, secret, public, max_votes, bars) VALUES (?, ?, ?, ?, ?, ?, ?, ?)""", (creator_id, message, locale, False, secret, public, max_votes, bars)) id = cur.lastrowid for number, name in enumerate(vote_options): cur.execute("""INSERT INTO VoteOptions (poll_id, name, number) VALUES (?, ?, ?)""", (id, name, number)) con.commit() return cls(con, id)
Example #3
Source File: poll.py From mattermost-poll with GNU General Public License v3.0 | 5 votes |
def load(cls, id): """Loads a poll from the database. Raise a InvalidPollError if no poll with that id exists. """ con = sqlite3.connect(settings.DATABASE) return cls(con, id)
Example #4
Source File: app.py From aiohttp-login with ISC License | 5 votes |
def create_app(loop): app = web.Application(loop=loop, debug=settings.DEBUG) setup_jinja(app, settings.DEBUG) aiohttp_session.setup(app, EncryptedCookieStorage( settings.SESSION_SECRET.encode('utf-8'), max_age=settings.SESSION_MAX_AGE)) app.middlewares.append(aiohttp_login.flash.middleware) app.router.add_get('/', handlers.index) app.router.add_get('/users/', handlers.users, name='users') app['db'] = await asyncpg.create_pool(dsn=settings.DATABASE, loop=loop) aiohttp_login.setup(app, AsyncpgStorage(app['db']), settings.AUTH) return app
Example #5
Source File: manager.py From twitch-chat-logger with MIT License | 5 votes |
def __init__(self, channels_amount, channels, log_filename=None): self.bots = [] self.channels_amount = channels_amount self.log_filename = log_filename self.channels = channels self.db_logger = DatabaseLogger(settings.DATABASE['HOST'], settings.DATABASE['NAME'], settings.DATABASE['USER'], settings.DATABASE['PASSWORD'])
Example #6
Source File: manager.py From twitch-chat-logger with MIT License | 5 votes |
def _create_bot(self, name, channels): conn = IRCConnection(settings.IRC['SERVER'], settings.IRC['PORT'], settings.IRC['NICK'], settings.IRC['PASSWORD'], self.log_filename) bot_db_logger = DatabaseLogger(settings.DATABASE['HOST'], settings.DATABASE['NAME'], settings.DATABASE['USER'], settings.DATABASE['PASSWORD']) bot = TwitchBot(name, conn, bot_db_logger, Queue.Queue(), self.log_filename) bot.daemon = True bot.connect_and_join_channels(channels) bot.start() return bot