Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
concepts-processing
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Package registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor 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
meldb
concepts-processing
Commits
aa86013b
Commit
aa86013b
authored
3 months ago
by
mjbonifa
Browse files
Options
Downloads
Patches
Plain Diff
not dumped all database tables to file on export so they can be versioned
parent
4cbcdfe5
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
acmc/omop.py
+15
-1
15 additions, 1 deletion
acmc/omop.py
with
15 additions
and
1 deletion
acmc/omop.py
+
15
−
1
View file @
aa86013b
...
...
@@ -186,7 +186,7 @@ def concept_set_exist(cursor, concept_set_name):
cursor
.
execute
(
query
,
(
concept_set_name
,))
# 1 if exists, 0 otherwise
return
cursor
.
fetchone
()[
0
]
1
return
cursor
.
fetchone
()[
0
]
==
1
def
export
(
map_path
,
export_path
,
version
,
omop_metadata
):
logger
.
debug
(
f
"
exporting with metadata
{
omop_metadata
}
at version
{
version
}
"
)
...
...
@@ -271,6 +271,20 @@ def export(map_path, export_path, version, omop_metadata):
df_out
[
"
concept_set_id
"
]
=
concept_set_id
df_out
.
to_sql
(
"
CONCEPT_SET_ITEM
"
,
conn
,
if_exists
=
'
append
'
,
index
=
False
)
# Output all tables to CSV
# Get the list of all tables
cur
.
execute
(
"
SELECT name FROM sqlite_master WHERE type=
'
table
'
;
"
)
tables
=
cur
.
fetchall
()
# List of tables
# Export each table to a separate CSV file
for
table
in
tables
:
table_name
=
table
[
0
]
# Extract table name
df
=
pd
.
read_sql_query
(
f
"
SELECT * FROM
{
table_name
}
"
,
conn
)
output_file
=
f
"
{
table_name
}
.csv
"
output_path
=
export_path
/
output_file
df
.
to_csv
(
output_path
,
index
=
False
)
# Save as CSV
logger
.
info
(
f
"
Exported
{
table_name
}
to
{
table_name
}
.csv
"
)
conn
.
close
()
logger
.
debug
(
f
"
Created export db successfully
"
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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