Oh, duh! I just had the wrong string format. I knew I was doing
something dumb but I couldn't place my finger on it.
Thanks a ton!!!

On Jun 13, 4:06 pm, Michael Bayer <mike...@zzzcomputing.com> wrote:
> On Jun 13, 2012, at 3:40 PM, Michael Bayer wrote:
>
>
>
> >> I'm unable to query this field when I try this:
>
> >> site_id = UNIQUEIDENTIFIER(GUID_STR)
>
> > Not sure what this is supposed to do.  Seems like you're attempting to call 
> > the type as a function.  I've googled around and cannot find an example of 
> > what this would represent on SQL server ( 
> > i.e.http://msdn.microsoft.com/en-us/library/ms190215%28v=sql.105%29.aspx,http://msdn.microsoft.com/en-us/library/ms187942.aspx).
> >     From what I can see, "uniqueidentifier" is a type only, not a function.
>
> > Types, like String, VARCHAR, UNIQUEIDENTIFIER here, are meant to be called 
> > in two places - in CREATE TABLE statements and in CAST statements.  If 
> > there's some data-level procedure or something, that would be something 
> > else, such as a function you'd invoke in SQLAlchemy as 
> > func.uniqueidentifier(value).   But I can't find documentation for such a 
> > function, if you can point me to the SQL you want then your issue is solved.
>
> oh, you just want to query against a string guid.   Just pass it in as a 
> string, sorry.
>
> from sqlalchemy import MetaData, Table, Column, create_engine
> from sqlalchemy.dialects.mssql import UNIQUEIDENTIFIER
> import uuid
>
> m = MetaData()
> t1 = Table('t', m, Column('id', UNIQUEIDENTIFIER))
>
> e = create_engine("mssql://scott:tiger@ms_2005")
> with e.begin() as conn:
>     m.create_all(conn)
>
>     id_str = str(uuid.uuid4())
>     conn.execute(t1.insert(), id=id_str)
>     print conn.execute(t1.select().where(t1.c.id==id_str)).first()

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

Reply via email to