Преглед на файлове

reconfiguring database import and adding practice

practices
Simon Bowie преди 1 година
родител
ревизия
44faa963fd
променени са 2 файла, в които са добавени 6 реда и са изтрити 5 реда
  1. +5
    -5
      database_functions.sh
  2. +1
    -0
      web/app/practice.py

+ 5
- 5
database_functions.sh Целия файл

@@ -40,29 +40,29 @@ Help()

Export()
{
docker exec -it $CONTAINER mysqldump --single-transaction -u $USERNAME -p$PASSWORD $DATABASE > $EXPORT_DIRECTORY/$EXPORT_SQL_FILENAME`date +"%Y%m%d"`.sql
docker exec -it $CONTAINER mariadb-dump --single-transaction -u $USERNAME -p$PASSWORD $DATABASE > $EXPORT_DIRECTORY/$EXPORT_SQL_FILENAME`date +"%Y%m%d"`.sql
}

Import()
{
docker exec -i $CONTAINER mysql -u $USERNAME -p$PASSWORD $DATABASE < $IMPORT_SQL_FILE
docker exec -i $CONTAINER mariadb -u $USERNAME -p$PASSWORD $DATABASE < $IMPORT_SQL_FILE
}

Table_export()
{
docker exec -it $CONTAINER bash -c "mysql -u $USERNAME -p$PASSWORD $DATABASE --batch -e 'SELECT * FROM $TABLE'" > $EXPORT_TXT_DIRECTORY/$EXPORT_TXT_FILENAME.txt
docker exec -it $CONTAINER bash -c "mariadb -u $USERNAME -p$PASSWORD $DATABASE --batch -e 'SELECT * FROM $TABLE'" > $EXPORT_TXT_DIRECTORY/$EXPORT_TXT_FILENAME.txt
}

Table_import()
{
docker cp $IMPORT_TXT_FILE $CONTAINER:/tmp/import_file

docker exec -i $CONTAINER bash -c "mysql -u $USERNAME -p$PASSWORD $DATABASE -e 'LOAD DATA LOCAL INFILE '\''/tmp/import_file'\'' REPLACE INTO TABLE $TABLE FIELDS TERMINATED BY '\''\t'\'' LINES TERMINATED BY '\''\r'\'' IGNORE 1 ROWS;'"
docker exec -i $CONTAINER bash -c "mariadb -u $USERNAME -p$PASSWORD $DATABASE -e 'LOAD DATA LOCAL INFILE '\''/tmp/import_file'\'' REPLACE INTO TABLE $TABLE FIELDS TERMINATED BY '\''\t'\'' LINES TERMINATED BY '\''\r'\'' IGNORE 1 ROWS;'"
}

Drop_table()
{
docker exec -i $CONTAINER bash -c "mysql -u $USERNAME -p$PASSWORD $DATABASE -e 'DROP TABLE IF EXISTS $TABLE;'"
docker exec -i $CONTAINER bash -c "mariadb -u $USERNAME -p$PASSWORD $DATABASE -e 'DROP TABLE IF EXISTS $TABLE;'"
}
############################################################
############################################################

+ 1
- 0
web/app/practice.py Целия файл

@@ -36,6 +36,7 @@ def get_practices():
Resource.id==59,
Resource.id==62,
Resource.id==63,
Resource.id==64,
Resource.id==65,
Resource.id==66
))

Loading…
Отказ
Запис