Deleted dakosdump
This commit is contained in:
parent
2a204465b0
commit
336748a04e
4 changed files with 0 additions and 427 deletions
File diff suppressed because one or more lines are too long
|
@ -1,65 +0,0 @@
|
||||||
import os
|
|
||||||
import datetime
|
|
||||||
import sqlite3
|
|
||||||
|
|
||||||
from django.utils.html import escape
|
|
||||||
|
|
||||||
from seminar import ovvpfile
|
|
||||||
from seminar.models import Problem
|
|
||||||
from seminar.utils import roman, from_roman
|
|
||||||
|
|
||||||
|
|
||||||
# MM_ZADANIA.TYP
|
|
||||||
typtable={'1': Problem.TYP_ULOHA, '2':Problem.TYP_TEMA, '3':Problem.TYP_SERIAL}
|
|
||||||
|
|
||||||
# MM_DOZ.ZARADENIE, MM_AZAD.ZAMERANIE
|
|
||||||
def dectag(x):
|
|
||||||
return ["MFIOTKPZD"[bi] for bi in range(0, 9) if (int(x) & (1 << bi))]
|
|
||||||
|
|
||||||
# Datum z formatu "DD.MM.YY"
|
|
||||||
def transdate(s):
|
|
||||||
if '.' not in s: return None
|
|
||||||
d,m,r = map(int, s.split('.'))
|
|
||||||
return datetime.date(r + 2000 if r < 30 else r + 1900, m, d)
|
|
||||||
|
|
||||||
class SQLiteRow(object):
|
|
||||||
def __unicode__(self):
|
|
||||||
return self.__dict__.__unicode__()
|
|
||||||
def __str__(self):
|
|
||||||
return self.__dict__.__str__()
|
|
||||||
def __repr__(self):
|
|
||||||
return self.__dict__.__str__()
|
|
||||||
|
|
||||||
# sqlite3 helper
|
|
||||||
def sqget(db, sql, limit=None):
|
|
||||||
c = db.execute(sql)
|
|
||||||
rows = c.fetchmany(limit) if limit else c.fetchall()
|
|
||||||
res = []
|
|
||||||
for row in rows:
|
|
||||||
o = SQLiteRow()
|
|
||||||
for coli in range(len(c.description)):
|
|
||||||
col = c.description[coli]
|
|
||||||
o.__setattr__(col[0], row[coli])
|
|
||||||
res.append(o)
|
|
||||||
return res
|
|
||||||
|
|
||||||
## ovvpfile - based import helpers (old)
|
|
||||||
|
|
||||||
def read_all_tables(basedir):
|
|
||||||
tables = {}
|
|
||||||
for fn in os.listdir(basedir):
|
|
||||||
if fn.endswith('.csv'):
|
|
||||||
print "Reading %s ..." % (fn, )
|
|
||||||
with open(os.path.join(basedir, fn), 'r') as f:
|
|
||||||
o = ovvpfile.parse(f, with_headers=False)
|
|
||||||
tables[fn[:-4]] = o.rows
|
|
||||||
print " %d lines, columns: %s" % (len(o.rows), ' '.join(o.columns), )
|
|
||||||
return tables
|
|
||||||
|
|
||||||
def matchrows(tab, key, val):
|
|
||||||
return [r for r in tab if r[key]==val]
|
|
||||||
|
|
||||||
def onerow(tab, key, val):
|
|
||||||
t = matchrows(tab, key, val)
|
|
||||||
assert(len(t) == 1)
|
|
||||||
return t[0]
|
|
|
@ -1,54 +0,0 @@
|
||||||
#!/usr/bin/perl
|
|
||||||
|
|
||||||
# RUN AS:
|
|
||||||
#
|
|
||||||
# ORACLE_HOME=/nfs/nikam/sw/oracle-10.2/ora_home_10.2/ LC_ALL=C AESOP_PASSWD=<password-of-MAMOPER> perl oracle_dump
|
|
||||||
#
|
|
||||||
|
|
||||||
use strict;
|
|
||||||
use warnings;
|
|
||||||
use utf8;
|
|
||||||
|
|
||||||
use lib '/nfs/nikam/sw/oracle-10.2/perl/lib/perl';
|
|
||||||
use DBI;
|
|
||||||
use DBD::Oracle qw(:ora_types);
|
|
||||||
$ENV{'NLS_LANG'}='CZECH.UTF8';
|
|
||||||
|
|
||||||
|
|
||||||
my $pass = $ENV{'AESOP_PASSWD'} // die "You must set AESOP_PASSWD\n";
|
|
||||||
my $dbh = DBI->connect('dbi:Oracle:host=mffout.karlov.mff.cuni.cz;service_name=mffout.karlov.mff.cuni.cz;port=1521',
|
|
||||||
'mamoper', $pass, {ora_connect_with_default_signals => [ 'INT' ], 'LongReadLen' => 1000000 }) or die;
|
|
||||||
|
|
||||||
$, = "\t";
|
|
||||||
$\ = "\n";
|
|
||||||
my $dump_directory = "oracle_dks_dump";
|
|
||||||
mkdir $dump_directory unless -d $dump_directory;
|
|
||||||
|
|
||||||
sub dump_table($){
|
|
||||||
my $name = shift;
|
|
||||||
print $name;
|
|
||||||
my $filename = $dump_directory."/".$name.".csv";
|
|
||||||
open(my $fh, ">:encoding(UTF-8)", $filename);
|
|
||||||
select $fh;
|
|
||||||
my $query = $dbh->prepare("SELECT * FROM $name");
|
|
||||||
$query->execute;
|
|
||||||
print @{$query->{NAME}};
|
|
||||||
print @{$query->{TYPE}};
|
|
||||||
while (my @row = $query->fetchrow_array()) {
|
|
||||||
$_//='' for @row;
|
|
||||||
s/\t/\\t/g for @row;
|
|
||||||
s/\n/\\n/g for @row;
|
|
||||||
print @row;
|
|
||||||
}
|
|
||||||
select STDOUT;
|
|
||||||
close $fh;
|
|
||||||
}
|
|
||||||
|
|
||||||
# my $query = $dbh->prepare("SELECT table_name, TABLESPACE_NAME FROM all_tables WHERE owner='MAMOPER'");
|
|
||||||
my $query = $dbh->prepare("SELECT table_name, owner FROM all_tables");
|
|
||||||
$query->execute;
|
|
||||||
while (my @row = $query->fetchrow_array()) {
|
|
||||||
if (!( $row[1] eq 'SYS')) {
|
|
||||||
dump_table "$row[1].$row[0]";
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue