feat: New database with a lot of modeles associated to sets and less pieces than before.
This commit is contained in:
parent
7613866ff4
commit
2961cbb1fa
@ -1,5 +1,7 @@
|
|||||||
DIR_SRC = src
|
DIR_SRC = src
|
||||||
DIR_BUILD = build
|
DIR_BUILD = build
|
||||||
|
DIR_CSV = .csv
|
||||||
|
DIR_DATA = .data
|
||||||
|
|
||||||
all: build
|
all: build
|
||||||
|
|
||||||
@ -11,9 +13,26 @@ build: \
|
|||||||
$(DIR_BUILD)/05_functions.sql
|
$(DIR_BUILD)/05_functions.sql
|
||||||
# $(DIR_BUILD)/03_select.sql \
|
# $(DIR_BUILD)/03_select.sql \
|
||||||
|
|
||||||
generate_data:
|
# Data generation
|
||||||
|
|
||||||
|
generate_data: gen rework convert
|
||||||
|
|
||||||
|
gen:
|
||||||
python3 generate_data.py
|
python3 generate_data.py
|
||||||
rm .data/*.data
|
|
||||||
|
to_rework = $(DIR_DATA)/{acheter,contenir,enregistrer,construire,necessiter,noter}.data
|
||||||
|
|
||||||
|
rework:
|
||||||
|
for toto in $(to_rework); do \
|
||||||
|
(cat $$toto | sort -u -t, -k1,2 | sort > tunexistespas); \
|
||||||
|
mv tunexistespas $$toto; \
|
||||||
|
done
|
||||||
|
|
||||||
|
convert:
|
||||||
|
python3 convert_data.py
|
||||||
|
rm $(DIR_DATA)/*.data
|
||||||
|
rm -fr __pycache__
|
||||||
|
###
|
||||||
|
|
||||||
$(DIR_BUILD)/00_drop.sql: $(DIR_SRC)/drop.sql
|
$(DIR_BUILD)/00_drop.sql: $(DIR_SRC)/drop.sql
|
||||||
mkdir -p $(dir $@)
|
mkdir -p $(dir $@)
|
||||||
@ -40,6 +59,6 @@ $(DIR_BUILD)/05_functions.sql: $(DIR_SRC)/functions.sql
|
|||||||
cp $< $@
|
cp $< $@
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f $(DIR_BUILD)/* .data/*.data
|
rm -f $(DIR_BUILD)/* $(DIR_DATA)/*.data
|
||||||
|
|
||||||
.PHONY: clean build all generate_data
|
.PHONY: clean build all generate_data
|
||||||
|
26
PostgreSQL/convert_data.py
Normal file
26
PostgreSQL/convert_data.py
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
from generate_data import tablesDict
|
||||||
|
from generate_data import give_path_file
|
||||||
|
from generate_data import remove_duplicata
|
||||||
|
from generate_data import convert_table_to_sql
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
###########################################################################
|
||||||
|
#
|
||||||
|
# To write `insert.sql`.
|
||||||
|
#
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
|
# First, remove duplicatas.
|
||||||
|
for name in tablesDict:
|
||||||
|
remove_duplicata(give_path_file(name))
|
||||||
|
|
||||||
|
# Writing in `insert.sql`.
|
||||||
|
fileSql = open("src/insert.sql", 'w+')
|
||||||
|
fileSql.write("TRUNCATE " + ', '.join(tablesDict) + ";\n")
|
||||||
|
fileSql.write("\n")
|
||||||
|
fileSql.close()
|
||||||
|
|
||||||
|
with open("src/insert.sql", 'a') as fileSql:
|
||||||
|
for nameTable in tablesDict:
|
||||||
|
convert_table_to_sql(give_path_file(nameTable), nameTable)
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user