Use etlalchemy for the migration
This commit is contained in:
parent
95850dc4f8
commit
388814bb3f
|
@ -0,0 +1,25 @@
|
|||
from etlalchemy import ETLAlchemySource, ETLAlchemyTarget
|
||||
|
||||
source = ETLAlchemySource(
|
||||
"sqlite:///databases/odyfo.db",
|
||||
included_tables=[
|
||||
"users",
|
||||
"cities",
|
||||
"games",
|
||||
"payments",
|
||||
"player_availabilities",
|
||||
"player_cancel_games",
|
||||
"purchase_games",
|
||||
"sports",
|
||||
"teams",
|
||||
"user_ratings",
|
||||
"venue_images",
|
||||
"venues",
|
||||
"web_bookings",
|
||||
],
|
||||
)
|
||||
target = ETLAlchemyTarget(
|
||||
"postgresql+psycopg2://postgres@localhost/odyfo", drop_database=True
|
||||
)
|
||||
target.addSource(source)
|
||||
target.migrate()
|
10
shell.nix
10
shell.nix
|
@ -8,7 +8,7 @@ let
|
|||
origin = "databases/odyfo.db";
|
||||
|
||||
in mkShell {
|
||||
buildInputs = [ postgresql sqlite ];
|
||||
buildInputs = [ postgresql python27 python27Packages.virtualenv ];
|
||||
|
||||
shellHook = ''
|
||||
trap "kill 0" EXIT
|
||||
|
@ -23,10 +23,14 @@ in mkShell {
|
|||
pg_ctl start -o "--unix_socket_directories=${data_dir} --listen_addresses='''"
|
||||
fi
|
||||
|
||||
psql -d postgres -f ${sql_file}
|
||||
|
||||
alias psql='psql -d postgres'
|
||||
alias nuke='rm -rf ${data_dir}'
|
||||
|
||||
# Workaround to use pip
|
||||
SOURCE_DATE_EPOCH=$(date +%s)
|
||||
virtualenv .venv
|
||||
export PATH=$PWD/.venv/bin:$PATH
|
||||
pip install etlalchemy
|
||||
pip install psycopg2
|
||||
'';
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue