Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SMPPIR-Tables
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SMPPIR
SMPPIR-Tables
Commits
6e732f1d
Commit
6e732f1d
authored
6 years ago
by
Rafael S Castilho
Browse files
Options
Downloads
Patches
Plain Diff
add update generation script
parent
420b7738
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Scripts/caseMake.py
+42
-0
42 additions, 0 deletions
Scripts/caseMake.py
Table_definition/fies.sql
+1
-0
1 addition, 0 deletions
Table_definition/fies.sql
Table_definition/institutionPrivate.sql
+2
-1
2 additions, 1 deletion
Table_definition/institutionPrivate.sql
with
45 additions
and
1 deletion
Scripts/caseMake.py
0 → 100755
+
42
−
0
View file @
6e732f1d
#!/usr/bin/env python3
import
sys
import
pymonetdb
## function to create a series of updates to set the new info
# on the table that is missing it
def
makeUpdate
(
outfile
,
table
,
col
,
col1
,
ano
,
QR
):
out
=
open
(
outfile
,
'
w
'
)
for
i
in
QR
:
print
(
"
UPDATE
"
,
table
,
file
=
out
)
print
(
"
SET
"
,
col1
,
"
=
\'
"
,
i
[
1
].
replace
(
"
\'
"
,
"
\\\'
"
),
"
\'
"
,
sep
=
''
,
file
=
out
,
end
=
'
'
)
print
(
"
WHERE ano_censo =
"
,
ano
,
"
AND
"
,
col
,
"
=
"
,
i
[
0
],
"
;
"
,
file
=
out
)
## function to make querries in the database and
# save the results in QR
def
querryDatabase
(
QR
):
connection
=
pymonetdb
.
connect
(
username
=
"
monetdb
"
,
password
=
"
monetdb
"
,
hostname
=
"
localhost
"
,
database
=
"
dados_educacionais
"
)
cursor
=
connection
.
cursor
()
cursor
.
arraysize
=
100
cursor
.
execute
(
'
SELECT DISTINCT
'
+
col
+
'
,
'
+
col1
+
'
FROM
'
+
table
+
'
WHERE ano_censo =
'
+
ano
+
'
ORDER BY
'
+
col
)
# select must happen in COD, NAME fashion, or the case
# generation will go wrong
QR
.
append
(
cursor
.
fetchall
())
col
=
sys
.
argv
[
1
]
# col with code
col1
=
sys
.
argv
[
2
]
# col with name
outfile
=
sys
.
argv
[
3
]
# name of output file
table
=
sys
.
argv
[
4
]
# table to be querryed
tableUp
=
sys
.
argv
[
5
]
# table to be updated
ano
=
sys
.
argv
[
6
]
# year to apply update
querryRes
=
[]
# will recieve database querry result
querryDatabase
(
querryRes
)
QR
=
querryRes
[
0
]
querryRes
=
[]
makeUpdate
(
outfile
,
tableUp
,
col
,
col1
,
ano
,
QR
)
This diff is collapsed.
Click to expand it.
Table_definition/fies.sql
+
1
−
0
View file @
6e732f1d
...
@@ -52,3 +52,4 @@ ORDER BY
...
@@ -52,3 +52,4 @@ ORDER BY
estado
.
regiao_id
ASC
,
estado
.
regiao_id
ASC
,
fies
.
ano_censo
ASC
,
fies
.
ano_censo
ASC
,
ano_censo
ASC
ano_censo
ASC
;
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Table_definition/institutionPrivate.sql
+
2
−
1
View file @
6e732f1d
...
@@ -26,4 +26,5 @@ GROUP BY
...
@@ -26,4 +26,5 @@ GROUP BY
ORDER
BY
ORDER
BY
inst
.
ano_censo
ASC
,
inst
.
ano_censo
ASC
,
nome_ies
ASC
nome_ies
ASC
\ No newline at end of file
;
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