[sqlalchemy] tablet version cache

2013-05-09 Thread Treeve Jelbert
i have started having problems when casting spells.
I get message:

The tablet version cache is damaged, removing it!

In some cases it appears multiple times.

I tried 'cleanse --tablet' but it makes no difference.

Any ideas?





Waiting for any Solo casts to complete... 
Waiting for any other casts of libxslt to complete... done.
Staging enabled
castfs: checking sanity of mnt-dir and stage-dir
castfs: stagedir is okay!
Preparing libxslt
GPG checking source file libxslt-1.1.28.tar.gz...
gpg: Signature made Thu May  9 00:44:21 2013 CEST using RSA key ID 285B52A7
gpg: BAD signature from Ladislav Hagara (Source Mage GNU/Linux Signing Key) 
lhag...@sourcemage.org
gpg: binary signature, digest algorithm SHA512
Failure to verify gpg signature
The tablet version cache is damaged, removing it!

Creating the tablet version cache, this can take a while ...
rm: cannot remove '/tmp/sorcery/cast/18220/install_queue': No such file or 
directory
rm: cannot remove '/tmp/sorcery/cast/18220/recheck_queue': No such file or 
directory
Abort? [y] n
Unpacking source file libxslt-1.1.28.tar.gz for spell libxslt.
Building libxslt
Preparing to install libxslt
Dispelled spell: libxslt
Installing libxslt into the system
The tablet version cache is damaged, removing it!

Creating the tablet version cache, this can take a while ...
Creating compile log /var/log/sorcery/compile/libxslt-1.1.28.bz2 
Creating castfs debug log 
/var/log/sorcery/compile/libxslt-1.1.28.castfs.dbglog.bz2 
Creating tablet in directory /var/state/sorcery/tablet/libxslt/20130509090944
Creating install log /var/log/sorcery/install/libxslt-1.1.28
Creating MD5 log /var/log/sorcery/md5sum/libxslt-1.1.28
Creating cache file /var/cache/sorcery/x86_64/libxslt-1.1.28-x86_64-pc-linux-
gnu.tar.bz2
Finished processing install requests.

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [sqlalchemy] ColanderAlchemy 0.2a1 released!

2013-05-09 Thread Stefano Fontanelli
Hi Lycovian,
you can check Deform: https://pypi.python.org/pypi/deform/
Then use ColanderAlchemy with Deform.

I also worked on a DeformAlchemy:
https://github.com/stefanofontanelli/DeformAlchemy
Unfortunately I have no time to complete it. I used in production but I
think it needs more work to be stable.

Let me know you need more info/help.



2013/5/7 Lycovian mfwil...@gmail.com

 Looks interesting.  Can you give a concrete use case for this library?
  I'm looking for something that can automatically generate a user form
 (HTML) to accept input from arbitrary models.  Would this lib help with
 that?

 mfw

 On Friday, April 12, 2013 10:10:45 AM UTC-7, Stefano Fontanelli wrote:


 Fixed.
 Thank you for the feedback.

 I also noticed that 0.2a1 release was hidden. I fixed it and it is
 visible now. Sorry.

 S.

 2013/4/11 Werner werner...@sfr.fr

  On 12/04/2013 00:01, Stefano Fontanelli wrote:

 Hi all,
 ColanderAlchemy 0.2a1 has been released on PyPi.

  We are waiting feedbacks to add/remove/change features before reach
 beta version.

  You can find changelog here: https://github.com/**stefanofontanelli/**
 ColanderAlchemy/blob/master/**CHANGELOG.txthttps://github.com/stefanofontanelli/ColanderAlchemy/blob/master/CHANGELOG.txt

  You can find new doc here:
 https://colanderalchemy.**readthedocs.org/en/latest/https://colanderalchemy.readthedocs.org/en/latest/

 BTW, the colander link on the following page does not work.

 Werner

 --
 You received this message because you are subscribed to the Google
 Groups sqlalchemy group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to sqlalchemy+...@**googlegroups.com.
 To post to this group, send email to sqlal...@googlegroups.com.

 Visit this group at 
 http://groups.google.com/**group/sqlalchemy?hl=enhttp://groups.google.com/group/sqlalchemy?hl=en
 .
 For more options, visit 
 https://groups.google.com/**groups/opt_outhttps://groups.google.com/groups/opt_out
 .




  --
 You received this message because you are subscribed to the Google Groups
 sqlalchemy group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to sqlalchemy+unsubscr...@googlegroups.com.
 To post to this group, send email to sqlalchemy@googlegroups.com.
 Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [sqlalchemy] tablet version cache

2013-05-09 Thread Simon King
On Thu, May 9, 2013 at 9:02 AM, Treeve Jelbert tre...@scarlet.be wrote:
 i have started having problems when casting spells.
 I get message:

 The tablet version cache is damaged, removing it!

 In some cases it appears multiple times.

 I tried 'cleanse --tablet' but it makes no difference.

 Any ideas?





 Waiting for any Solo casts to complete...
 Waiting for any other casts of libxslt to complete... done.
 Staging enabled
 castfs: checking sanity of mnt-dir and stage-dir
 castfs: stagedir is okay!
 Preparing libxslt
 GPG checking source file libxslt-1.1.28.tar.gz...
 gpg: Signature made Thu May  9 00:44:21 2013 CEST using RSA key ID 285B52A7
 gpg: BAD signature from Ladislav Hagara (Source Mage GNU/Linux Signing Key)
 lhag...@sourcemage.org
 gpg: binary signature, digest algorithm SHA512
 Failure to verify gpg signature
 The tablet version cache is damaged, removing it!

 Creating the tablet version cache, this can take a while ...
 rm: cannot remove '/tmp/sorcery/cast/18220/install_queue': No such file or
 directory
 rm: cannot remove '/tmp/sorcery/cast/18220/recheck_queue': No such file or
 directory
 Abort? [y] n
 Unpacking source file libxslt-1.1.28.tar.gz for spell libxslt.
 Building libxslt
 Preparing to install libxslt
 Dispelled spell: libxslt
 Installing libxslt into the system
 The tablet version cache is damaged, removing it!

 Creating the tablet version cache, this can take a while ...
 Creating compile log /var/log/sorcery/compile/libxslt-1.1.28.bz2
 Creating castfs debug log
 /var/log/sorcery/compile/libxslt-1.1.28.castfs.dbglog.bz2
 Creating tablet in directory /var/state/sorcery/tablet/libxslt/20130509090944
 Creating install log /var/log/sorcery/install/libxslt-1.1.28
 Creating MD5 log /var/log/sorcery/md5sum/libxslt-1.1.28
 Creating cache file /var/cache/sorcery/x86_64/libxslt-1.1.28-x86_64-pc-linux-
 gnu.tar.bz2
 Finished processing install requests.

I think you're on the wrong mailing list... This is SQLAlchemy
(www.sqlalchemy.org). I guess you're talking about
http://www.sourcemage.org/?

Simon

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




[sqlalchemy] Query.update() and joins

2013-05-09 Thread Tobias Bieniek
Hi guys,

I have stripped down my problematic code to the following: 
http://pastebin.com/AvvEr103

I am trying to call the Query.update() method on a query that is using an 
innerjoin to load some more information that I use in a filter. If I use 
the same expression to query data everything works fine, but once I call 
update() the join expression (Event.id == Notification.event_id) is no 
longer taken into account and the update() call updates all the rows in the 
table. I'm having the feeling that this might actually be a bug in 
SQLAlchemy. As you can see there is a workaround by simply adding the 
expression explicitly as a filter, but it would obviously be better to have 
this be the default behaviour.

Turbo

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




[sqlalchemy] How to use schema with DDL()

2013-05-09 Thread Wolfgang Meiners
Hi all,

i have a simple database that uses a trigger. After some searching
if found the following solution for my problem and everything works fine:

In this database i have to tables (valid, invalid) and i can in insert a
number into table valid only when this number is not in table invalid.
Of course, the real situation is more complicated, but this shows the
problem:


#!/usr/bin/env python3
# -*- coding: utf-8 -*-

'''
Created on 09.05.2013
Database interface for postgresql 9.1
Uses sqlalchemy 0.7.10, psycopg2 2.4.6, postgresql 9.1

@author: wolfgang
'''

from sqlalchemy import Integer,Column, create_engine, DDL, event
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm.session import sessionmaker

from locale import setlocale, LC_ALL

Base=declarative_base()
#Base.metadata.schema='test'

class Invalid(Base):
__tablename__ = 'invalid'

number = Column(Integer, primary_key=True)

def __init__(self, number):
self.number = number

class Valid(Base):
__tablename__ = 'valid'

number = Column(Integer, primary_key=True)

def __init__(self, number):
self.number = number

trigger_ddl = DDL('''
CREATE OR REPLACE FUNCTION validate_number() RETURNS TRIGGER
AS $$
BEGIN
IF EXISTS(
SELECT * FROM invalid WHERE number = NEW.number
)
THEN
RAISE EXCEPTION '%% is invalid', NEW.number;
RETURN NULL;
END IF;

RETURN NEW;
END;
$$ LANGUAGE plpgsql;

CREATE TRIGGER validate_number BEFORE INSERT OR UPDATE ON valid
FOR EACH ROW EXECUTE PROCEDURE validate_number();
''')

setlocale(LC_ALL,'')
url = 'postgresql+psycopg2://{u}:{pw}@{h}:{p}/{db}'.format(
 u='tester', pw='mypassword', h='localhost', p='5432', db='tester')
engine = create_engine(url, echo=True)

event.listen(Valid.__table__, 'after_create', Valid.trigger_ddl)
event.listen(Valid.__table__, 'after_drop',
 DDL('DROP FUNCTION validate_number() CASCADE;'))

Base.metadata.drop_all(engine)
Base.metadata.create_all(engine)
Session=sessionmaker(engine)
session = Session()

session.add(Invalid(3))
session.commit()

#works
session.add(Valid(1))
session.add(Valid(2))

session.commit()

#raises an error as expected
session.add(Valid(3))

try:
session.commit()
except:
session.rollback()

#Base.metadata.drop_all(engine)


Now i want to run everything inside the schema 'test'. Two questions arises:
1) How can i create schema test automatically when it does not exist?
   This should be somehow related to
   Base.metadata.create_all(engine)

2) If i create schema test by hand and uncomment the line
#Base.metadata.schema='test'
i get an errormessage because the DDL does not use schema test:
sqlalchemy.exc.ProgrammingError: (ProgrammingError) relation valid
does not exist

I think, this can not be difficult, but I have no idea, how to tell
sqlalchemy to use schema test in the DDL.

Maybe a third question: Can someone tell me, wether there is a better
(recommended) way to define triggers?

Thank you for any hint
Wolfgang

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [sqlalchemy] How to use schema with DDL()

2013-05-09 Thread Michael Bayer

On May 9, 2013, at 6:32 AM, Wolfgang Meiners wolfgangmeiner...@web.de wrote:

 
 Now i want to run everything inside the schema 'test'. Two questions arises:
 1) How can i create schema test automatically when it does not exist?
   This should be somehow related to
   Base.metadata.create_all(engine)

you'd use a DDL(CREATE SCHEMA foo) that's attached to the before_create 
event of the MetaData object.

 
 2) If i create schema test by hand and uncomment the line
 #Base.metadata.schema='test'
 i get an errormessage because the DDL does not use schema test:
 sqlalchemy.exc.ProgrammingError: (ProgrammingError) relation valid
 does not exist

you'd need to refer to the table valid as myschema.valid within the 
definition of your stored procedure.


-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [sqlalchemy] Query.update() and joins

2013-05-09 Thread Michael Bayer
An explicit JOIN isn't supported within an UPDATE statement on the Postgresql 
platform, SQLAlchemy supports UPDATE..FROM but you need to set up the join 
condition as an implicit join, which is what mark_type_read2 is essentially 
doing, establishing the equality between Event and Notification directly.

If you need to UPDATE against an actual outer join, you'd need to turn it 
into a correlated subquery in the WHERE clause of the UPDATE statement.




On May 9, 2013, at 6:11 AM, Tobias Bieniek tobias.bien...@googlemail.com 
wrote:

 Hi guys,
 
 I have stripped down my problematic code to the following: 
 http://pastebin.com/AvvEr103
 
 I am trying to call the Query.update() method on a query that is using an 
 innerjoin to load some more information that I use in a filter. If I use the 
 same expression to query data everything works fine, but once I call update() 
 the join expression (Event.id == Notification.event_id) is no longer taken 
 into account and the update() call updates all the rows in the table. I'm 
 having the feeling that this might actually be a bug in SQLAlchemy. As you 
 can see there is a workaround by simply adding the expression explicitly as a 
 filter, but it would obviously be better to have this be the default 
 behaviour.
 
 Turbo
 
 -- 
 You received this message because you are subscribed to the Google Groups 
 sqlalchemy group.
 To unsubscribe from this group and stop receiving emails from it, send an 
 email to sqlalchemy+unsubscr...@googlegroups.com.
 To post to this group, send email to sqlalchemy@googlegroups.com.
 Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
 For more options, visit https://groups.google.com/groups/opt_out.
  
  

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




[sqlalchemy] Re: How to use schema with DDL()

2013-05-09 Thread Wolfgang Meiners
Thank you very much for your hints. They were very helpful!

Am 09.05.13 16:16, schrieb Michael Bayer:
 
 On May 9, 2013, at 6:32 AM, Wolfgang Meiners wolfgangmeiner...@web.de wrote:
 

 Now i want to run everything inside the schema 'test'. Two questions arises:
 1) How can i create schema test automatically when it does not exist?
   This should be somehow related to
   Base.metadata.create_all(engine)
 
 you'd use a DDL(CREATE SCHEMA foo) that's attached to the before_create 
 event of the MetaData object.

that seems to be exactly what i was looking for. When i tried it out, i
run into an error because SCHEMA 'test' existed. Maybe the simplest
solution to this is
DDL('''DROP SCHEMA {s} CASCADING IF EXISTS;
   CREATE SCHEMA {s};'''.format(s=Base.metadata.schema))

I came up with a slighly different solution, see below.

 

 2) If i create schema test by hand and uncomment the line
 #Base.metadata.schema='test'
 i get an errormessage because the DDL does not use schema test:
 sqlalchemy.exc.ProgrammingError: (ProgrammingError) relation valid
 does not exist
 
 you'd need to refer to the table valid as myschema.valid within the 
 definition of your stored procedure.

and this can be achieved with a
... {s}valid \
format(s=Base.metadata.schema + '.' if Base.metadata.schema else '')


For the interested, here is a solution that works:
=
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

'''
Created on 09.05.2013
Database interface for postgresql 9.1
Uses sqlalchemy 0.7.10, psycopg2 2.4.6, postgresql 9.1

@author: wolfgang
'''

from sqlalchemy import Integer,Column, create_engine, DDL, event,
select, text
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm.session import sessionmaker

from locale import setlocale, LC_ALL

Base=declarative_base()
Base.metadata.schema='test'

class Invalid(Base):
__tablename__ = 'invalid'

number = Column(Integer, primary_key=True)

def __init__(self, number):
self.number = number

class Valid(Base):
__tablename__ = 'valid'

number = Column(Integer, primary_key=True)

def __init__(self, number):
self.number = number

trigger_ddl = DDL('''
CREATE OR REPLACE FUNCTION {s}validate_number()
RETURNS TRIGGER AS $$
BEGIN
IF EXISTS(
SELECT * FROM {s}invalid WHERE number = NEW.number
)
THEN
RAISE EXCEPTION '%% is invalid', NEW.number;
RETURN NULL;
END IF;

RETURN NEW;
END;
$$ LANGUAGE plpgsql;

CREATE TRIGGER validate_number
BEFORE INSERT OR UPDATE ON {s}valid
FOR EACH ROW EXECUTE PROCEDURE {s}validate_number();
'''.format(s=Base.metadata.schema + '.' if Base.metadata.schema else
''))

setlocale(LC_ALL,'')
url = 'postgresql+psycopg2://{u}:{pw}@{h}:{p}/{db}'.format(
  u='tester', pw='mypassword', h='localhost', p='5432', db='tester')
engine = create_engine(url, echo=True)

event.listen(Valid.__table__, 'after_create', Valid.trigger_ddl)
event.listen(Valid.__table__, 'after_drop',
 DDL('DROP FUNCTION {s}validate_number() CASCADE;'.\
 format(s = Base.metadata.schema + '.' if\
Base.metadata.schema else '')))

Base.metadata.drop_all(engine)

myschema = Base.metadata.schema
if myschema is not None:
t = text(SELECT schema_name FROM information_schema.schemata WHERE
schema_name = '{s}'.format(s=myschema))
r = engine.connect().execute(t).fetchall()
if not r:
ddl_before = DDL('CREATE SCHEMA {s}'.format(s=myschema))
event.listen(Base.metadata, 'before_create', ddl_before)

ddl_after  = DDL('DROP SCHEMA {s}'.format(s=myschema))
event.listen(Base.metadata, 'after_drop', ddl_after)

Base.metadata.create_all(engine)
Session=sessionmaker(engine)
session = Session()

session.add(Invalid(3))
session.commit()

#works
session.add(Valid(1))
session.add(Valid(2))

session.commit()

#raises an error
session.add(Valid(3))

try:
session.commit()
except:
session.rollback()

qv = session.query(Valid)
for v in qv: print('number {v} is valid'.format(v=v.number))

session.close()

Base.metadata.drop_all(engine)
=



-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




[sqlalchemy] Re: Casting an overlap filter as an array

2013-05-09 Thread Glenn Yonemitsu
Just like to bump this issue.

Is casting inside an overlap even possible? I've tried all sorts of 
variations of parameters to see what will stick. I either get the visit_X 
error or an uncasted query, which then postgresql says the  (overlap) 
operation is not allowed.




On Monday, May 6, 2013 2:04:57 PM UTC-4, Glenn Yonemitsu wrote:

 Hi, all.

 In Postgresql I have a CMS entry model with a tag column varchar(20)[]. I 
 want to do a query so a row with any of the tags will be returned. I know 
 overlap is the method to use but I can't get the casting done correctly.

 Right now I am trying (and a lot of searching revealed similar solutions):

 query.filter(ContentEntry.tag.overlap(cast(tags, ARRAY(VARCHAR(20)

 But I am getting the error: AttributeError: 'SQLCompiler' object has no 
 attribute 'visit_array'. Any variation involving ARRAY() or array() says 
 there is no attribute visit_ARRAY or visit_array.

 The following hand crafted SQL works, so for now I'm trying to at least 
 get to this point (and as I understand, overlap will use the  operator):

 SELECT content_entry.title, content_entry.tag FROM content_entry WHERE 
 content_entry.tag  cast(array['foo', 'bar'] as varchar(20)[]);

 How can I get this casted correctly?

 Thanks in advance.


-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.