Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
D
douban-api-proxy
Project
Project
Details
Activity
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
captainwong
douban-api-proxy
Commits
1535bdbc
Commit
1535bdbc
authored
Aug 15, 2020
by
OzzieIsaacs
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'memorydatabase/issue/1564'
parents
ecb160b2
0e1ec503
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
8 deletions
+8
-8
admin.py
cps/admin.py
+1
-1
db.py
cps/db.py
+6
-6
gdrive.py
cps/gdrive.py
+1
-1
No files found.
cps/admin.py
View file @
1535bdbc
...
...
@@ -99,7 +99,7 @@ def shutdown():
if
task
==
2
:
log
.
warning
(
"reconnecting to calibre database"
)
calibre_db
.
setup
_db
(
config
,
ub
.
app_DB_path
)
calibre_db
.
reconnect
_db
(
config
,
ub
.
app_DB_path
)
showtext
[
'text'
]
=
_
(
u'Reconnect successful'
)
return
json
.
dumps
(
showtext
)
...
...
cps/db.py
View file @
1535bdbc
...
...
@@ -32,6 +32,7 @@ from sqlalchemy import String, Integer, Boolean, TIMESTAMP, Float
from
sqlalchemy.orm
import
relationship
,
sessionmaker
,
scoped_session
from
sqlalchemy.ext.declarative
import
declarative_base
from
sqlalchemy.exc
import
OperationalError
from
sqlalchemy.pool
import
StaticPool
from
flask_login
import
current_user
from
sqlalchemy.sql.expression
import
and_
,
true
,
false
,
text
,
func
,
or_
from
sqlalchemy.ext.associationproxy
import
association_proxy
...
...
@@ -371,7 +372,6 @@ class CalibreDB(threading.Thread):
def
setup_db
(
self
,
config
,
app_db_path
):
self
.
config
=
config
self
.
dispose
()
# global engine
if
not
config
.
config_calibre_dir
:
config
.
invalidate
()
...
...
@@ -383,11 +383,11 @@ class CalibreDB(threading.Thread):
return
False
try
:
#engine = create_engine('sqlite:///{0}'.format(dbpath),
self
.
engine
=
create_engine
(
'sqlite://'
,
echo
=
False
,
isolation_level
=
"SERIALIZABLE"
,
connect_args
=
{
'check_same_thread'
:
False
})
connect_args
=
{
'check_same_thread'
:
False
},
poolclass
=
StaticPool
)
self
.
engine
.
execute
(
"attach database '{}' as calibre;"
.
format
(
dbpath
))
self
.
engine
.
execute
(
"attach database '{}' as app_settings;"
.
format
(
app_db_path
))
...
...
@@ -417,10 +417,10 @@ class CalibreDB(threading.Thread):
str
(
row
.
id
)
+
'.id'
),
primary_key
=
True
),
'extra'
:
Column
(
Float
),
'asoc'
:
relationship
(
'
Custom_C
olumn_'
+
str
(
row
.
id
),
uselist
=
False
),
'asoc'
:
relationship
(
'
custom_c
olumn_'
+
str
(
row
.
id
),
uselist
=
False
),
'value'
:
association_proxy
(
'asoc'
,
'value'
)
}
books_custom_column_links
[
row
.
id
]
=
type
(
str
(
'
Books_Custom_C
olumn_'
+
str
(
row
.
id
)
+
'_link'
),
books_custom_column_links
[
row
.
id
]
=
type
(
str
(
'
books_custom_c
olumn_'
+
str
(
row
.
id
)
+
'_link'
),
(
Base
,),
dicttable
)
else
:
books_custom_column_links
[
row
.
id
]
=
Table
(
'books_custom_column_'
+
str
(
row
.
id
)
+
'_link'
,
...
...
@@ -446,7 +446,7 @@ class CalibreDB(threading.Thread):
ccdict
[
'value'
]
=
Column
(
String
)
if
row
.
datatype
in
[
'float'
,
'int'
,
'bool'
]:
ccdict
[
'book'
]
=
Column
(
Integer
,
ForeignKey
(
'books.id'
))
cc_classes
[
row
.
id
]
=
type
(
str
(
'
Custom_C
olumn_'
+
str
(
row
.
id
)),
(
Base
,),
ccdict
)
cc_classes
[
row
.
id
]
=
type
(
str
(
'
custom_c
olumn_'
+
str
(
row
.
id
)),
(
Base
,),
ccdict
)
for
cc_id
in
cc_ids
:
if
(
cc_id
[
1
]
==
'bool'
)
or
(
cc_id
[
1
]
==
'int'
)
or
(
cc_id
[
1
]
==
'float'
):
...
...
cps/gdrive.py
View file @
1535bdbc
...
...
@@ -154,7 +154,7 @@ def on_received_watch_confirmation():
log
.
info
(
'Setting up new DB'
)
# prevent error on windows, as os.rename does on exisiting files
move
(
os
.
path
.
join
(
tmpDir
,
"tmp_metadata.db"
),
dbpath
)
calibre_db
.
setup
_db
(
config
,
ub
.
app_DB_path
)
calibre_db
.
reconnect
_db
(
config
,
ub
.
app_DB_path
)
except
Exception
as
e
:
log
.
exception
(
e
)
updateMetaData
()
...
...
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