Skip to content
Snippets Groups Projects
Commit 71a88e84 authored by Pierre-antoine Comby's avatar Pierre-antoine Comby
Browse files

initiate import command

parent f13ccf11
No related branches found
No related tags found
1 merge request!19Import nk15
Pipeline #7708 passed with stage
in 2 minutes and 52 seconds
#!/usr/env/bin python3
from django.core.management.base import BaseCommand
from django.utils import timezone
import psycopg2 as pg
import json
class Command(BaseCommand):
"""
Command for importing the database of NK15.
Need to be run by a user with a registered role in postgres for the database nk15.
"""
help = 'Displays current time'
def add_arguments(self,parser):
parser.add_argument("--map",type=str,help="json mapping of table header to field models")
def handle(self, *args, **options):
map_file= options.get("map",None)
with open(map_file,'rb') as f:
map_dict = json.load(f);
#conn = pg.connect(database="nk15",user="nk_15")
#cur = conn.cursor()
for old_table in map_dict:
print(old_table)
[
"comptes": {
"idbde":"Note.id",
"type": null,
"pseudo":"User.username",
"passwd":"User.password",
"solde":"Note.solde",
"nom":"User.first_name",
"prenom":"User.last_name",
"tel":"Profile.phone_number",
"mail":"User.email",
"adresse":"Profile.address",
"fonction": null,
"normalien": "Profile.paid",
"pbsante": null,
"droit": null,
"surdroit": null,
"supreme": null,
"bloque": null,
"last_adhesion": null
},
"transaction":{
"id":"Transaction.id",
"date":"Transaction.created_at",
"type": null,
"emetteur":"Transaction.source_id",
"destinataire":"Transaction.destination_id",
"quantite":"Transaction.quantity",
"montant":"Transaction.amount",
"description":"Transaction.reason",
"valide":"Transaction.valid",
"cantinvalidate": null,
"categorie":"Transaction.transaction_type"
},
"boutons":{
"id":"TransactionTemplate.id",
"label":"TransactionTemplate.name",
"montant":"TransactionTemplate.amount",
"destinataire":"TransactionTemplate.destination_id",
"categorie":null,
"affiche":null,
"description":null,
"consigne":null
},
"aliases":{
"id":"Alias.id",
"alias":"Alias.name",
"idbde":"Alias.note_id"
}
]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment