def sql_login(user, password):
        connect_args = Manager.connect_args_tmp.format('postgres', user,
                                                       password)
        cookie = Manager.cookie

        try:
            connect = psycopg2.connect(connect_args)
            cookie["user"] = user
            cookie["password"] = password
            connect.close()
            print(cookie)
            template.redirect('../cgi-bin/select_db.py')
        except:
            template.redirect('../cgi-bin/user_login_error.py')
#!/home/mrdiz/anaconda3/bin/python

import sys
sys.path.append("/home/mrdiz/SQL/Lab5(2)")

import cgi
from utils.site_manager import Manager
import utils.site_template as template

form = cgi.FieldStorage()

is_select = form.getfirst('SELECT')
is_insert = form.getfirst('INSERT')
is_update = form.getfirst('UPDATE')
is_delete = form.getfirst('DELETE')

grants_list = (is_select, is_insert, is_update, is_delete)

Manager.sql_set_grants(grants_list)

template.redirect('users_list_tables_grants.py')
Пример #3
0
#!/home/mrdiz/anaconda3/bin/python

import sys
sys.path.append("/home/mrdiz/SQL/Lab5(2)")

import cgi
from utils.site_manager import Manager
import utils.site_template as template

form = cgi.FieldStorage()
selected_db = form.getfirst('db_list')

Manager.cookie["database"] = selected_db
print(Manager.cookie)

template.redirect('select_db_tables.py')
sys.path.append("/home/mrdiz/SQL/Lab5(2)")

import cgi
import html

from utils.site_manager import Manager
import utils.site_template as template

selected_table = Manager.cookie["table"].value

headers_list = Manager.sql_select(
    'column_name, data_type', 'information_schema.columns',
    "(table_schema='public') AND (table_name='{0}')".format(selected_table))

headers_values = []

form = cgi.FieldStorage()

for item in headers_list:
    value = form.getfirst(item[0])
    type = item[1]
    value = html.escape(value)

    list_item = (value, type)

    headers_values.append(list_item)

Manager.sql_insert(selected_table, headers_values)

template.redirect('table_insert.py')
Пример #5
0
#!/home/mrdiz/anaconda3/bin/python

import sys
sys.path.append("/home/mrdiz/SQL/Lab5(2)")

import cgi

from utils.site_manager import Manager
import utils.site_template as template

form = cgi.FieldStorage()
selected_table = form.getfirst('table_list')

Manager.cookie["table"] = selected_table
print(Manager.cookie)

template.redirect('table.py')
sys.path.append("/home/mrdiz/SQL/Lab5(2)")

import re
import cgi

from utils.site_manager import Manager
import utils.site_template as template

form = cgi.FieldStorage()

selected_table = Manager.cookie["table"].value
selected_row = form.getfirst('row_delete')

headers_list = Manager.sql_select(
    'column_name, column_default', 'information_schema.columns',
    "(table_schema='public') AND (table_name='{0}')".format(selected_table))

re_match = r"nextval\('.*'::regclass\)"
pk_column = ''

for item in headers_list:
    res = re.search(re_match, str(item[1]))

    if res:
        pk_column = item[0]
        break

Manager.sql_delete(selected_table, pk_column, selected_row)

template.redirect('table_delete.py')