Edited license

Desktop file in make
SQL conversion (probably will be deleted again)


git-svn-id: http://galileo.dmi.unict.it/svn/relational/trunk@219 014f5005-505e-4b48-8d0a-63407b615a7c
master
LtWorf 2010-02-24 00:46:58 +07:00
parent 8633052af2
commit 6adcd221bd
11 changed files with 148 additions and 30 deletions

@ -99,7 +99,7 @@ debian:
chmod a+x data/usr/bin/relational
#desktop file
mkdir -p data/usr/share/applications/
cp relational.desktop data/usr/share/applications/
cp debscript/relational.desktop data/usr/share/applications/
mkdir -p data/DEBIAN
#package description
debscript/gencontrol.sh > data/DEBIAN/control

@ -2,7 +2,7 @@
# Relational
# Copyright (C) 2009 Salvo "LtWorf" Tomaselli
#
# Relation is free software: you can redistribute it and/or modify
# Relational is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

@ -3,7 +3,7 @@
# Relational
# Copyright (C) 2008 Salvo "LtWorf" Tomaselli
#
# Relation is free software: you can redistribute it and/or modify
# Relational is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

@ -2,7 +2,7 @@
# Relational
# Copyright (C) 2009 Salvo "LtWorf" Tomaselli
#
# Relation is free software: you can redistribute it and/or modify
# Relational is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

@ -3,7 +3,7 @@
# Relational
# Copyright (C) 2008 Salvo "LtWorf" Tomaselli
#
# Relation is free software: you can redistribute it and/or modify
# Relational is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

@ -2,7 +2,7 @@
# Relational
# Copyright (C) 2008 Salvo "LtWorf" Tomaselli
#
# Relation is free software: you can redistribute it and/or modify
# Relational is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

@ -22,24 +22,6 @@
def stub():
"NATURAL JOIN"
"CROSS JOIN" ,
def sql2relational(query):
query=query.replace('\n',' ').replace(',',' , ')
t=query.split(' ')
escape=False
for i in range(len(t)):
tok=t[i].lower().strip()
if tok=='from' and not escape:
break
if tok in ('select','as',','):
escape=True
else:
escape=False
return extract_select(t[1:i])
def extract_select(query,internal=''):
@ -76,5 +58,134 @@ def extract_select(query,internal=''):
return result
def extract_from(query):
return query
def sql2relational(query):
query=query.replace('\n',' ').replace(',',' , ')
tokens=[]
t=query.split(' ')
escape=False
for i in range(len(t)):
tok=t[i].lower().strip()
if tok=='from' and not escape:
break
if tok in ('select','as',','):
escape=True
else:
escape=False
return extract_select(t[1:i])
class table(object):
def __init__(self):
self.attr=[]
self.realname=None
pass
sqlops=('SELECT','FROM','WHERE',',',';')
import optimizations
if __name__=="__main__":
print sql2relational('SELECT a,c AS q FROM from;')
query="SELECT * FROM a AS b,a WHERE a.id!= b.id and a.age<12 or b.sucation==4 or d=3;"
query=query.replace(',',' , ').replace(';',' ; ')
print query
parts=query.split(' ')
tokens=[]
temp=''
lastop=None
for i in parts:
if i in sqlops:
# TODO must tokenize (blabla(bla)) as a single token
if lastop == 'WHERE': #Where is a special case, must tokenize all the stuff
for j in optimizations.tokenize_select(temp):
tokens.append(j.strip())
else:
tokens.append(temp.strip())
tokens.append(i.strip())
temp=''
lastop=i
else:
temp+=i+' '
tokens=tokens[1:] #Removes futile 1st empty element
print tokens
rels={}
from_=[]
where_=[]
select_=[]
for i in tokens:
if i in ('SELECT','FROM','WHERE'):
last=i
continue
if last=='FROM':
if ' AS ' in i:
parts=i.split(' AS ')
rels[parts[1].strip()]=table()
rels[parts[1].strip()].realname=parts[0].strip()
from_.append(parts[1].strip())
pass
else:
if i!=',':
rels[i.strip()]=table()
from_.append(i.strip())
pass
elif last=='WHERE':
where_.append(i)
if i in optimizations.sel_op:
continue
if '.' in i:
parts=i.split('.',1)
if parts[1] not in rels[parts[0]].attr:
rels[parts[0]].attr.append(parts[1])
elif last=='SELECT':
# TODO should do like the same of WHERE but supporting AS too
pass
for i in rels.keys():
print "========" + i + "========"
print rels[i].attr
print rels[i].realname
print from_
for i in from_:
if i in rels.keys():
print i
#print sql2relational('SELECT a,c AS q FROM from;')

@ -4,7 +4,7 @@
# Relational
# Copyright (C) 2008 Salvo "LtWorf" Tomaselli
#
# Relation is free software: you can redistribute it and/or modify
# Relational is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
@ -31,7 +31,14 @@ about.version=version
if __name__ == "__main__":
if len (sys.argv) > 1 and sys.argv[1] == "-v":
print version
print "Relational"
print "This program comes with ABSOLUTELY NO WARRANTY."
print "This is free software, and you are welcome to redistribute it"
print "under certain conditions."
print "For details see the GPLv3 Licese."
print
print "Version: %s"%version
sys.exit(0)
try:

@ -2,7 +2,7 @@
# Relational
# Copyright (C) 2008 Salvo "LtWorf" Tomaselli
#
# Relation is free software: you can redistribute it and/or modify
# Relational is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

@ -2,7 +2,7 @@
# Relational
# Copyright (C) 2008 Salvo "LtWorf" Tomaselli
#
# Relation is free software: you can redistribute it and/or modify
# Relational is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

@ -2,7 +2,7 @@
# Relational
# Copyright (C) 2008 Salvo "LtWorf" Tomaselli
#
# Relation is free software: you can redistribute it and/or modify
# Relational is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.