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
f9c6fb30
Commit
f9c6fb30
authored
Aug 14, 2020
by
OzzieIsaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Excluded series type again, as it causes problems upon reconnect
parent
94ad93eb
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
47 deletions
+47
-47
db.py
cps/db.py
+2
-2
ub.py
cps/ub.py
+45
-45
No files found.
cps/db.py
View file @
f9c6fb30
...
...
@@ -49,7 +49,7 @@ except ImportError:
use_unidecode
=
False
cc_exceptions
=
[
'datetime'
,
'comments'
,
'composite'
]
cc_exceptions
=
[
'datetime'
,
'comments'
,
'composite'
,
'series'
]
cc_classes
=
{}
Base
=
declarative_base
()
...
...
@@ -453,7 +453,7 @@ class CalibreDB(threading.Thread):
setattr
(
Books
,
'custom_column_'
+
str
(
cc_id
[
0
]),
relationship
(
cc_classes
[
cc_id
[
0
]],
primaryjoin
=
(
# ToDo: Check Remove
primaryjoin
=
(
Books
.
id
==
cc_classes
[
cc_id
[
0
]]
.
book
),
backref
=
'books'
))
elif
(
cc_id
[
1
]
==
'series'
):
...
...
cps/ub.py
View file @
f9c6fb30
...
...
@@ -474,14 +474,14 @@ def migrate_Database(session):
ArchivedBook
.
__table__
.
create
(
bind
=
engine
)
if
not
engine
.
dialect
.
has_table
(
engine
.
connect
(),
"registration"
):
ReadBook
.
__table__
.
create
(
bind
=
engine
)
conn
=
engine
.
connect
()
with
engine
.
connect
()
as
conn
:
conn
.
execute
(
"insert into registration (domain, allow) values('
%
.
%
',1)"
)
session
.
commit
()
try
:
session
.
query
(
exists
()
.
where
(
Registration
.
allow
))
.
scalar
()
session
.
commit
()
except
exc
.
OperationalError
:
# Database is not compatible, some columns are missing
conn
=
engine
.
connect
()
with
engine
.
connect
()
as
conn
:
conn
.
execute
(
"ALTER TABLE registration ADD column 'allow' INTEGER"
)
conn
.
execute
(
"update registration set 'allow' = 1"
)
session
.
commit
()
...
...
@@ -489,14 +489,14 @@ def migrate_Database(session):
session
.
query
(
exists
()
.
where
(
RemoteAuthToken
.
token_type
))
.
scalar
()
session
.
commit
()
except
exc
.
OperationalError
:
# Database is not compatible, some columns are missing
conn
=
engine
.
connect
()
with
engine
.
connect
()
as
conn
:
conn
.
execute
(
"ALTER TABLE remote_auth_token ADD column 'token_type' INTEGER DEFAULT 0"
)
conn
.
execute
(
"update remote_auth_token set 'token_type' = 0"
)
session
.
commit
()
try
:
session
.
query
(
exists
()
.
where
(
ReadBook
.
read_status
))
.
scalar
()
except
exc
.
OperationalError
:
conn
=
engine
.
connect
()
with
engine
.
connect
()
as
conn
:
conn
.
execute
(
"ALTER TABLE book_read_link ADD column 'read_status' INTEGER DEFAULT 0"
)
conn
.
execute
(
"UPDATE book_read_link SET 'read_status' = 1 WHERE is_read"
)
conn
.
execute
(
"ALTER TABLE book_read_link ADD column 'last_modified' DATETIME"
)
...
...
@@ -510,7 +510,7 @@ def migrate_Database(session):
try
:
session
.
query
(
exists
()
.
where
(
Shelf
.
uuid
))
.
scalar
()
except
exc
.
OperationalError
:
conn
=
engine
.
connect
()
with
engine
.
connect
()
as
conn
:
conn
.
execute
(
"ALTER TABLE shelf ADD column 'uuid' STRING"
)
conn
.
execute
(
"ALTER TABLE shelf ADD column 'created' DATETIME"
)
conn
.
execute
(
"ALTER TABLE shelf ADD column 'last_modified' DATETIME"
)
...
...
@@ -525,30 +525,30 @@ def migrate_Database(session):
# Handle table exists, but no content
cnt
=
session
.
query
(
Registration
)
.
count
()
if
not
cnt
:
conn
=
engine
.
connect
()
with
engine
.
connect
()
as
conn
:
conn
.
execute
(
"insert into registration (domain, allow) values('
%
.
%
',1)"
)
session
.
commit
()
try
:
session
.
query
(
exists
()
.
where
(
BookShelf
.
order
))
.
scalar
()
except
exc
.
OperationalError
:
# Database is not compatible, some columns are missing
conn
=
engine
.
connect
()
with
engine
.
connect
()
as
conn
:
conn
.
execute
(
"ALTER TABLE book_shelf_link ADD column 'order' INTEGER DEFAULT 1"
)
session
.
commit
()
try
:
create
=
False
session
.
query
(
exists
()
.
where
(
User
.
sidebar_view
))
.
scalar
()
except
exc
.
OperationalError
:
# Database is not compatible, some columns are missing
conn
=
engine
.
connect
()
with
engine
.
connect
()
as
conn
:
conn
.
execute
(
"ALTER TABLE user ADD column `sidebar_view` Integer DEFAULT 1"
)
session
.
commit
()
create
=
True
try
:
if
create
:
conn
=
engine
.
connect
()
with
engine
.
connect
()
as
conn
:
conn
.
execute
(
"SELECT language_books FROM user"
)
session
.
commit
()
except
exc
.
OperationalError
:
conn
=
engine
.
connect
()
with
engine
.
connect
()
as
conn
:
conn
.
execute
(
"UPDATE user SET 'sidebar_view' = (random_books* :side_random + language_books * :side_lang "
"+ series_books * :side_series + category_books * :side_category + hot_books * "
":side_hot + :side_autor + :detail_random)"
,
...
...
@@ -560,7 +560,7 @@ def migrate_Database(session):
try
:
session
.
query
(
exists
()
.
where
(
User
.
denied_tags
))
.
scalar
()
except
exc
.
OperationalError
:
# Database is not compatible, some columns are missing
conn
=
engine
.
connect
()
with
engine
.
connect
()
as
conn
:
conn
.
execute
(
"ALTER TABLE user ADD column `denied_tags` String DEFAULT ''"
)
conn
.
execute
(
"ALTER TABLE user ADD column `allowed_tags` String DEFAULT ''"
)
conn
.
execute
(
"ALTER TABLE user ADD column `denied_column_value` String DEFAULT ''"
)
...
...
@@ -569,7 +569,7 @@ def migrate_Database(session):
try
:
session
.
query
(
exists
()
.
where
(
User
.
series_view
))
.
scalar
()
except
exc
.
OperationalError
:
conn
=
engine
.
connect
()
with
engine
.
connect
()
as
conn
:
conn
.
execute
(
"ALTER TABLE user ADD column `series_view` VARCHAR(10) DEFAULT 'list'"
)
if
session
.
query
(
User
)
.
filter
(
User
.
role
.
op
(
'&'
)(
constants
.
ROLE_ANONYMOUS
)
==
constants
.
ROLE_ANONYMOUS
)
.
first
()
\
...
...
@@ -577,11 +577,11 @@ def migrate_Database(session):
create_anonymous_user
(
session
)
try
:
# check if one table with autoincrement is existing (should be user table)
conn
=
engine
.
connect
()
with
engine
.
connect
()
as
conn
:
conn
.
execute
(
"SELECT COUNT(*) FROM sqlite_sequence WHERE name='user'"
)
except
exc
.
OperationalError
:
# Create new table user_id and copy contents of table user into it
conn
=
engine
.
connect
()
with
engine
.
connect
()
as
conn
:
conn
.
execute
(
"CREATE TABLE user_id (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,"
"nickname VARCHAR(64),"
"email VARCHAR(120),"
...
...
@@ -605,7 +605,7 @@ def migrate_Database(session):
# Remove login capability of user Guest
try
:
conn
=
engine
.
connect
()
with
engine
.
connect
()
as
conn
:
conn
.
execute
(
"UPDATE user SET password='' where nickname = 'Guest' and password !=''"
)
session
.
commit
()
except
exc
.
OperationalError
:
...
...
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