-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'fix-game-outcomes' of github.com:Wesmania/server into t…
…rueskill-ranks
- Loading branch information
Showing
54 changed files
with
1,981 additions
and
1,818 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,36 @@ | ||
from aiomysql.sa import create_engine | ||
|
||
engine = None | ||
|
||
class FAFDatabase: | ||
def __init__(self, loop): | ||
self._loop = loop | ||
self.engine = None | ||
|
||
def set_engine(engine_): | ||
""" | ||
Set the globally used engine to the given argument | ||
""" | ||
global engine | ||
engine = engine_ | ||
async def connect(self, host='localhost', port=3306, user='root', | ||
password='', db='faf_test', minsize=1, maxsize=1, | ||
echo=True): | ||
if self.engine is not None: | ||
raise ValueError("DB is already connected!") | ||
self.engine = await create_engine( | ||
host=host, | ||
port=port, | ||
user=user, | ||
password=password, | ||
db=db, | ||
autocommit=True, | ||
loop=self._loop, | ||
minsize=minsize, | ||
maxsize=maxsize, | ||
echo=echo | ||
) | ||
|
||
def acquire(self): | ||
return self.engine.acquire() | ||
|
||
async def connect_engine( | ||
loop, host='localhost', port=3306, user='root', password='', db='faf_test', | ||
minsize=1, maxsize=1, echo=True | ||
): | ||
engine = await create_engine( | ||
host=host, | ||
port=port, | ||
user=user, | ||
password=password, | ||
db=db, | ||
autocommit=True, | ||
loop=loop, | ||
minsize=minsize, | ||
maxsize=maxsize, | ||
echo=echo | ||
) | ||
async def close(self): | ||
if self.engine is None: | ||
return | ||
|
||
set_engine(engine) | ||
return engine | ||
self.engine.close() | ||
await self.engine.wait_closed() | ||
self.engine = None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.