Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
ippidb-web
Manage
Activity
Members
Labels
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
iPPIDB
ippidb-web
Commits
004f4690
Commit
004f4690
authored
7 years ago
by
Hervé MENAGER
Browse files
Options
Downloads
Patches
Plain Diff
add mysql convertor to avoid "bytearray" strings from mysql driver
Former-commit-id: 64c85ed8155a7034a145bc99b364c1f68a623def
parent
8efe9f64
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ippisite/db.sqlite3.REMOVED.git-id
+1
-1
1 addition, 1 deletion
ippisite/db.sqlite3.REMOVED.git-id
ippisite/ippidb/management/commands/import_v1_data.py
+13
-1
13 additions, 1 deletion
ippisite/ippidb/management/commands/import_v1_data.py
with
14 additions
and
2 deletions
ippisite/db.sqlite3.REMOVED.git-id
+
1
−
1
View file @
004f4690
22fcf51cee85dcecd7c0de2fecdd0852abb2ce71
2b15950995d163e68e50e2aabf1b4e9a4ff2dfeb
\ No newline at end of file
\ No newline at end of file
This diff is collapsed.
Click to expand it.
ippisite/ippidb/management/commands/import_v1_data.py
+
13
−
1
View file @
004f4690
...
@@ -9,6 +9,18 @@ from ippidb.models import Bibliography, Protein, Taxonomy, MolecularFunction, \
...
@@ -9,6 +9,18 @@ from ippidb.models import Bibliography, Protein, Taxonomy, MolecularFunction, \
Domain
,
ProteinDomainBoundComplex
,
ProteinDomainPartnerComplex
,
Symmetry
,
Ppi
,
PpiComplex
,
Disease
,
\
Domain
,
ProteinDomainBoundComplex
,
ProteinDomainPartnerComplex
,
Symmetry
,
Ppi
,
PpiComplex
,
Disease
,
\
Compound
,
MDDRCompoundImport
,
MDDRActivityClass
Compound
,
MDDRCompoundImport
,
MDDRActivityClass
class
MyConverter
(
mysql
.
connector
.
conversion
.
MySQLConverter
):
def
row_to_python
(
self
,
row
,
fields
):
row
=
super
(
MyConverter
,
self
).
row_to_python
(
row
,
fields
)
def
to_unicode
(
col
):
if
type
(
col
)
==
bytearray
:
return
col
.
decode
(
'
utf-8
'
)
return
col
return
[
to_unicode
(
col
)
for
col
in
row
]
class
Command
(
BaseCommand
):
class
Command
(
BaseCommand
):
help
=
"
Import data from the local v1 database
"
help
=
"
Import data from the local v1 database
"
...
@@ -73,7 +85,7 @@ class Command(BaseCommand):
...
@@ -73,7 +85,7 @@ class Command(BaseCommand):
def
handle
(
self
,
*
args
,
**
options
):
def
handle
(
self
,
*
args
,
**
options
):
conn
=
mysql
.
connector
.
connect
(
host
=
"
localhost
"
,
user
=
"
root
"
,
password
=
"
ippidb
"
,
database
=
"
ippidb
"
)
conn
=
mysql
.
connector
.
connect
(
converter_class
=
MyConverter
,
host
=
"
localhost
"
,
user
=
"
root
"
,
password
=
"
ippidb
"
,
database
=
"
ippidb
"
)
cursor
=
conn
.
cursor
()
cursor
=
conn
.
cursor
()
if
options
[
'
bibliographies
'
]:
if
options
[
'
bibliographies
'
]:
cursor
.
execute
(
"""
SELECT * FROM biblio
"""
)
cursor
.
execute
(
"""
SELECT * FROM biblio
"""
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment