Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
humanities
gargantext
Commits
71937a5b
Commit
71937a5b
authored
Jan 13, 2016
by
delanoe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FIX] Try to fix parallelism bug with a session manager.
parent
daf4e9d3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
2 deletions
+5
-2
db.py
gargantext_web/db.py
+5
-2
No files found.
gargantext_web/db.py
View file @
71937a5b
...
@@ -7,13 +7,15 @@ __all__ = ['literalquery', 'session', 'cache', 'Session', 'bulk_insert', 'engine
...
@@ -7,13 +7,15 @@ __all__ = ['literalquery', 'session', 'cache', 'Session', 'bulk_insert', 'engine
# initialize sqlalchemy
# initialize sqlalchemy
from
sqlalchemy.orm
import
Session
,
mapper
from
sqlalchemy.orm
import
Session
,
mapper
,
scoped_session
,
sessionmaker
from
sqlalchemy.ext.automap
import
automap_base
from
sqlalchemy.ext.automap
import
automap_base
from
sqlalchemy
import
create_engine
,
MetaData
,
Table
,
Column
,
ForeignKey
from
sqlalchemy
import
create_engine
,
MetaData
,
Table
,
Column
,
ForeignKey
from
sqlalchemy.types
import
Integer
,
String
,
DateTime
from
sqlalchemy.types
import
Integer
,
String
,
DateTime
from
sqlalchemy.dialects.postgresql
import
JSON
from
sqlalchemy.dialects.postgresql
import
JSON
# SQLAlchemy session management
# SQLAlchemy session management
def
get_engine
():
def
get_engine
():
from
sqlalchemy
import
create_engine
from
sqlalchemy
import
create_engine
...
@@ -129,12 +131,13 @@ def literalquery(statement, dialect=None):
...
@@ -129,12 +131,13 @@ def literalquery(statement, dialect=None):
return
LiteralCompiler
(
dialect
,
statement
)
return
LiteralCompiler
(
dialect
,
statement
)
def
get_sessionmaker
():
def
get_sessionmaker
():
from
sqlalchemy.orm
import
sessionmaker
from
sqlalchemy.orm
import
sessionmaker
return
sessionmaker
(
bind
=
engine
)
return
sessionmaker
(
bind
=
engine
)
Session
=
get_sessionmaker
()
Session
=
get_sessionmaker
()
session
=
Session
(
)
session
=
scoped_session
(
Session
)
# SQLAlchemy model objects caching
# SQLAlchemy model objects caching
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment