problem creating users via pythons script
this is really newb of me but i can't manage to make a script to create
users.
cur.execute("""CREATE USER %s WITH PASSWORD %s IN GROUP %s
""",(StaffUserName,NewPassword,StaffGroup))
produces this error
ERROR: syntax error at or near "'bob.smith'" at character 13
is it because i need to double quote or something? i'm sure the answer
is stupid and i'm just too tired.
On Jul 19 10:02, Timothy Smith wrote:
cur.execute("""CREATE USER %s WITH PASSWORD %s IN GROUP %s
""",(StaffUserName,NewPassword,StaffGroup))produces this error
ERROR: syntax error at or near "'bob.smith'" at character 13
IIRC, per Python DB-API PEP, the DB adapter you use try to escape and
quote any parameter you specified. Please try to use python parameters,
that are "% (param1, param2, ...)", only for values; not for any other
place in the query string.
To summarize, you can only use parameters for values, not keys.
Regards.
On Jul 19 10:40, Timothy Smith wrote:
Volkan YAZICI wrote:
On Jul 19 10:02, Timothy Smith wrote:
cur.execute("""CREATE USER %s WITH PASSWORD %s IN GROUP %s
""",(StaffUserName,NewPassword,StaffGroup))produces this error
ERROR: syntax error at or near "'bob.smith'" at character 13
IIRC, per Python DB-API PEP, the DB adapter you use try to escape and
quote any parameter you specified. Please try to use python parameters,
that are "% (param1, param2, ...)", only for values; not for any other
Edit: �% (param1, param2, ...)� part must be replaced with
�"query_str", param1, param2, ...�
place in the query string.
To summarize, you can only use parameters for values, not keys.
...
ah ok so how do i do it :/
Just don't pass username as parameter to Cursor.execute(), for instance:
cur.execute("CREATE USER %s WITH PASSWORD %s IN GROUP %s"
% (StaffUserName, NewPassword, StaffGroup))
Regards.
P.S. Please don't forget to CC mailing list next time. Also, -interface
ml is more appropriate for these kind of questions.
Import Notes
Reply to msg id not found: 44BE2835.7010401@open-networks.net
Volkan YAZICI wrote:
On Jul 19 10:40, Timothy Smith wrote:
Volkan YAZICI wrote:
On Jul 19 10:02, Timothy Smith wrote:
cur.execute("""CREATE USER %s WITH PASSWORD %s IN GROUP %s
""",(StaffUserName,NewPassword,StaffGroup))produces this error
ERROR: syntax error at or near "'bob.smith'" at character 13
IIRC, per Python DB-API PEP, the DB adapter you use try to escape and
quote any parameter you specified. Please try to use python parameters,
that are "% (param1, param2, ...)", only for values; not for any otherEdit: �% (param1, param2, ...)� part must be replaced with
�"query_str", param1, param2, ...�place in the query string.
To summarize, you can only use parameters for values, not keys.
...
ah ok so how do i do it :/Just don't pass username as parameter to Cursor.execute(), for instance:
cur.execute("CREATE USER %s WITH PASSWORD %s IN GROUP %s"
% (StaffUserName, NewPassword, StaffGroup))Regards.
P.S. Please don't forget to CC mailing list next time. Also, -interface
ml is more appropriate for these kind of questions.
of course, i should have seen that to begin with, cheers.