Re: [sqlalchemy] Upgraded to 0.6beta3, getting a lot of "SAWarning: Unicode type received non-unicode bind param"
would have to see how you've set things up in order for that to occur. If you use the Unicode type with default settings, the behavior is the same on 0.5 and 0.6 - Python unicodes are expected and a warning is emitted otherwise. With String,VARCHAR, CHAR, etc., this is not the case and plain strings can be passed without warning. On Mar 31, 2010, at 5:59 PM, Peteris Krumins wrote: > Hi all, > > I upgraded to SA 0.6beta3 and suddenly I am getting a lot of > "SAWarning: Unicode type received non-unicode bind param value" > warnings for the code that worked OK on 0.5.x. The warnings occur even > for values that are plain ascii (no code points above 127). > > Does it mean I'll have to make sure my code uses Python unicode > strings everywhere, even if it they are ascii? > > Here are some of the warnings: > > /xyzzy/lib/python2.5/site-packages/SQLAlchemy-0.6beta3-py2.5.egg/ > sqlalchemy/dialects/mysql/base.py:960: SAWarning: Unicode type > received non-unicode bind param value '1' > > /xyzzy/lib/python2.5/site-packages/SQLAlchemy-0.6beta3-py2.5.egg/ > sqlalchemy/engine/default.py:472: SAWarning: Unicode type received non- > unicode bind param value 'application/pdf' > > /xyzzy/lib/python2.5/site-packages/SQLAlchemy-0.6beta3-py2.5.egg/ > sqlalchemy/engine/default.py:472: SAWarning: Unicode type received non- > unicode bind param value '1fd67ac4162561def609a4862677cdbc' > > > Sincerely, > P.Krumins > > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To post to this group, send email to sqlalch...@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. > -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@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.
[sqlalchemy] Re: where clause construction using variable names and values
@Conor - the where clause construction works now. Thanks for the reply on that. I have run into a new problem now. My select clauses have unicode names even when I construct them from vanilla strings. Here's my code: column_list = ["url", 'html'] what_fields = [meta.c[x] for x in column_list] print what_fields [Column(u'url', VARCHAR(length=None, convert_unicode=False, assert_unicode=None, unicode_error=None, _warn_on_bytestring=False), table=), Column(u'html', TEXT(length=None, convert_unicode=False, assert_unicode=None, unicode_error=None, _warn_on_bytestring=False), table=)] My table doesn't have column names that are unicode strings. Am I missing something here? -T On Mar 31, 4:43 pm, Tejaswi wrote: > On second thought, it's nothing to do with SA, and just a python > feature that I am not familiar with. The idiom of clause construction, > and passing arguments using the *list is new to me. And most of my > Google queries were prefixed with sqlalchemy, and in retrospect, that > was hurting more than helping. > > Thanks agian, > -T > > On Mar 31, 4:36 pm, Tejaswi wrote: > > > @Conor: This might be what I am looking for. I cannot try it right > > now, but will reply to this thread in 3-4 hours. > > > Can you please point me to the documentation that discusses the > > different ways of constructing select statements, where clauses, etc. > > I have not seen the generative way before. I tried really hard on > > Google, this forum specifically, stackoverflow, etc. The API > > documentation is sufficient, I am sure; but is not "tutorial" like. > > > Thanks again. This is greatly appreciated. > > > -T > > > On Mar 31, 4:10 pm, Conor wrote: > > > > Tejaswi wrote: > > > > I am not using sa.orm. I want to use only the sql expression syntax. > > > > > @Conor: I tried the dict approach. The problem is, I don't know how > > > > many key value pairs I will have. I will have to use a map, or map* to > > > > construct the full set of where clauses. This is the syntax I am not > > > > able to figure out. > > > > How about this: > > > > clauses = [meta.c[key] == value for (key, value) in dict.iteritems()] > > > select([table], and_(*clauses)) > > > > or, generatively: > > > > s = select([table]) > > > for (key, value) in dict.iteritems(): > > > s = s.where(meta.c[key] == value) > > > > -Conor > > > > > On Mar 31, 10:39 am, werner wrote: > > > > >> On 31/03/2010 08:19, Tejaswi wrote: > > > > >>> I have a dict of keys to values which have to go into my where clause > > > >>> with an and_. > > > > >>> Say dict = {"key1": value1, "key2": value2} > > > > >>> my select statement should look like select * from blah where key1 = > > > >>> value1 and key2 = value2 > > > > >>> I know this has to do with constructing the right where clause > > > >>> element, but I cannot seem to find documentation on it. > > > > >>> select([table], meta.c. == value) doesn't take a variable > > > >>> key. > > > > >>> Any help would be greatly appreciated. > > > > >> Are you using SA.orm? > > > > >> If yes, then you probably want to look at query.Query.filter and/or > > > >> query.Query.filter_by. > > > > >> Werner -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@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.
[sqlalchemy] Upgraded to 0.6beta3, getting a lot of "SAWarning: Unicode type received non-unicode bind param"
Hi all, I upgraded to SA 0.6beta3 and suddenly I am getting a lot of "SAWarning: Unicode type received non-unicode bind param value" warnings for the code that worked OK on 0.5.x. The warnings occur even for values that are plain ascii (no code points above 127). Does it mean I'll have to make sure my code uses Python unicode strings everywhere, even if it they are ascii? Here are some of the warnings: /xyzzy/lib/python2.5/site-packages/SQLAlchemy-0.6beta3-py2.5.egg/ sqlalchemy/dialects/mysql/base.py:960: SAWarning: Unicode type received non-unicode bind param value '1' /xyzzy/lib/python2.5/site-packages/SQLAlchemy-0.6beta3-py2.5.egg/ sqlalchemy/engine/default.py:472: SAWarning: Unicode type received non- unicode bind param value 'application/pdf' /xyzzy/lib/python2.5/site-packages/SQLAlchemy-0.6beta3-py2.5.egg/ sqlalchemy/engine/default.py:472: SAWarning: Unicode type received non- unicode bind param value '1fd67ac4162561def609a4862677cdbc' Sincerely, P.Krumins -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@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.
[sqlalchemy] sqlalchemy reflection
quick question: for sqlalchemy+ms sql server, what kind of accessibility does it need to do table reflection? What I am trying to do is that I try to reflect a table from an existing database, and I successfully created an engine. But I got following exception: raise exc.DBAPIError.instance(None, None, e) sqlalchemy.exc.ProgrammingError: (ProgrammingError) ('42000', '[42000] [Microsof t][ODBC SQL Server Driver][SQL Server]Cannot open database "HisTpwdCoastal" requ ested by the login. The login failed. (4060) (SQLDriverConnectW); [42000] [Micro soft][ODBC SQL Server Driver][SQL Server]Cannot open database "HisTpwdCoastal" r equested by the login. The login failed. (4060)') None None The connection string to mssql server only has delete, insert, and update capabilities . Wondering if any more capabilities needed. Thank you! -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@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.
[sqlalchemy] Re: where clause construction using variable names and values
On second thought, it's nothing to do with SA, and just a python feature that I am not familiar with. The idiom of clause construction, and passing arguments using the *list is new to me. And most of my Google queries were prefixed with sqlalchemy, and in retrospect, that was hurting more than helping. Thanks agian, -T On Mar 31, 4:36 pm, Tejaswi wrote: > @Conor: This might be what I am looking for. I cannot try it right > now, but will reply to this thread in 3-4 hours. > > Can you please point me to the documentation that discusses the > different ways of constructing select statements, where clauses, etc. > I have not seen the generative way before. I tried really hard on > Google, this forum specifically, stackoverflow, etc. The API > documentation is sufficient, I am sure; but is not "tutorial" like. > > Thanks again. This is greatly appreciated. > > -T > > On Mar 31, 4:10 pm, Conor wrote: > > > > > Tejaswi wrote: > > > I am not using sa.orm. I want to use only the sql expression syntax. > > > > @Conor: I tried the dict approach. The problem is, I don't know how > > > many key value pairs I will have. I will have to use a map, or map* to > > > construct the full set of where clauses. This is the syntax I am not > > > able to figure out. > > > How about this: > > > clauses = [meta.c[key] == value for (key, value) in dict.iteritems()] > > select([table], and_(*clauses)) > > > or, generatively: > > > s = select([table]) > > for (key, value) in dict.iteritems(): > > s = s.where(meta.c[key] == value) > > > -Conor > > > > On Mar 31, 10:39 am, werner wrote: > > > >> On 31/03/2010 08:19, Tejaswi wrote: > > > >>> I have a dict of keys to values which have to go into my where clause > > >>> with an and_. > > > >>> Say dict = {"key1": value1, "key2": value2} > > > >>> my select statement should look like select * from blah where key1 = > > >>> value1 and key2 = value2 > > > >>> I know this has to do with constructing the right where clause > > >>> element, but I cannot seem to find documentation on it. > > > >>> select([table], meta.c. == value) doesn't take a variable > > >>> key. > > > >>> Any help would be greatly appreciated. > > > >> Are you using SA.orm? > > > >> If yes, then you probably want to look at query.Query.filter and/or > > >> query.Query.filter_by. > > > >> Werner -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@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.
[sqlalchemy] Re: where clause construction using variable names and values
@Conor: This might be what I am looking for. I cannot try it right now, but will reply to this thread in 3-4 hours. Can you please point me to the documentation that discusses the different ways of constructing select statements, where clauses, etc. I have not seen the generative way before. I tried really hard on Google, this forum specifically, stackoverflow, etc. The API documentation is sufficient, I am sure; but is not "tutorial" like. Thanks again. This is greatly appreciated. -T On Mar 31, 4:10 pm, Conor wrote: > Tejaswi wrote: > > I am not using sa.orm. I want to use only the sql expression syntax. > > > @Conor: I tried the dict approach. The problem is, I don't know how > > many key value pairs I will have. I will have to use a map, or map* to > > construct the full set of where clauses. This is the syntax I am not > > able to figure out. > > How about this: > > clauses = [meta.c[key] == value for (key, value) in dict.iteritems()] > select([table], and_(*clauses)) > > or, generatively: > > s = select([table]) > for (key, value) in dict.iteritems(): > s = s.where(meta.c[key] == value) > > -Conor > > > > > On Mar 31, 10:39 am, werner wrote: > > >> On 31/03/2010 08:19, Tejaswi wrote: > > >>> I have a dict of keys to values which have to go into my where clause > >>> with an and_. > > >>> Say dict = {"key1": value1, "key2": value2} > > >>> my select statement should look like select * from blah where key1 = > >>> value1 and key2 = value2 > > >>> I know this has to do with constructing the right where clause > >>> element, but I cannot seem to find documentation on it. > > >>> select([table], meta.c. == value) doesn't take a variable > >>> key. > > >>> Any help would be greatly appreciated. > > >> Are you using SA.orm? > > >> If yes, then you probably want to look at query.Query.filter and/or > >> query.Query.filter_by. > > >> Werner -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@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.
Re: [sqlalchemy] Re: where clause construction using variable names and values
Tejaswi wrote: > I am not using sa.orm. I want to use only the sql expression syntax. > > @Conor: I tried the dict approach. The problem is, I don't know how > many key value pairs I will have. I will have to use a map, or map* to > construct the full set of where clauses. This is the syntax I am not > able to figure out. > > How about this: clauses = [meta.c[key] == value for (key, value) in dict.iteritems()] select([table], and_(*clauses)) or, generatively: s = select([table]) for (key, value) in dict.iteritems(): s = s.where(meta.c[key] == value) -Conor > On Mar 31, 10:39 am, werner wrote: > >> On 31/03/2010 08:19, Tejaswi wrote: >> >> >> >> >>> I have a dict of keys to values which have to go into my where clause >>> with an and_. >>> >>> Say dict = {"key1": value1, "key2": value2} >>> >>> my select statement should look like select * from blah where key1 = >>> value1 and key2 = value2 >>> >>> I know this has to do with constructing the right where clause >>> element, but I cannot seem to find documentation on it. >>> >>> select([table], meta.c. == value) doesn't take a variable >>> key. >>> >>> Any help would be greatly appreciated. >>> >> Are you using SA.orm? >> >> If yes, then you probably want to look at query.Query.filter and/or >> query.Query.filter_by. >> >> Werner >> > > -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@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.
[sqlalchemy] Re: where clause construction using variable names and values
I am not using sa.orm. I want to use only the sql expression syntax. @Conor: I tried the dict approach. The problem is, I don't know how many key value pairs I will have. I will have to use a map, or map* to construct the full set of where clauses. This is the syntax I am not able to figure out. Thanks for the replies. -T On Mar 31, 10:39 am, werner wrote: > On 31/03/2010 08:19, Tejaswi wrote: > > > > > I have a dict of keys to values which have to go into my where clause > > with an and_. > > > Say dict = {"key1": value1, "key2": value2} > > > my select statement should look like select * from blah where key1 = > > value1 and key2 = value2 > > > I know this has to do with constructing the right where clause > > element, but I cannot seem to find documentation on it. > > > select([table], meta.c. == value) doesn't take a variable > > key. > > > Any help would be greatly appreciated. > > Are you using SA.orm? > > If yes, then you probably want to look at query.Query.filter and/or > query.Query.filter_by. > > Werner -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@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.
Re: [sqlalchemy] where clause construction using variable names and values
On 31/03/2010 08:19, Tejaswi wrote: I have a dict of keys to values which have to go into my where clause with an and_. Say dict = {"key1": value1, "key2": value2} my select statement should look like select * from blah where key1 = value1 and key2 = value2 I know this has to do with constructing the right where clause element, but I cannot seem to find documentation on it. select([table], meta.c. == value) doesn't take a variable key. Any help would be greatly appreciated. Are you using SA.orm? If yes, then you probably want to look at query.Query.filter and/or query.Query.filter_by. Werner -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@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.
Re: [sqlalchemy] where clause construction using variable names and values
Tejaswi wrote: > I have a dict of keys to values which have to go into my where clause > with an and_. > > Say dict = {"key1": value1, "key2": value2} > > my select statement should look like select * from blah where key1 = > value1 and key2 = value2 > > I know this has to do with constructing the right where clause > element, but I cannot seem to find documentation on it. > > select([table], meta.c. == value) doesn't take a variable > key. > > Any help would be greatly appreciated. > > -T > > You can treat meta.c as a dict, e.g. meta.c[key] == value. -Conor -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@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.
[sqlalchemy] where clause construction using variable names and values
I have a dict of keys to values which have to go into my where clause with an and_. Say dict = {"key1": value1, "key2": value2} my select statement should look like select * from blah where key1 = value1 and key2 = value2 I know this has to do with constructing the right where clause element, but I cannot seem to find documentation on it. select([table], meta.c. == value) doesn't take a variable key. Any help would be greatly appreciated. -T -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@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.