Discussion:
MSSQL Connection String (sqlalchemy.url)
Victor Reichert
2013-06-13 22:58:30 UTC
Permalink
Hi,

I'm working through the Alembic tutorial and I have reached the point where
I need to enter the DB URL (sqlalchemy.url).

The URL below (with the DSN py_test) works and I am able to run my
migration, but I would like to connect without the DSN.

sqlalchemy.url = mssql+pyodbc://py_test; Trusted_Connection=Yes

I am able to connect to the DB with SQL Alchemy using the URL in the line
below:

sqlalchemy.url = mssql+pyodbc:///?odbc_connect=DRIVER={SQL
Server};Server=Server;Database=DB;Trusted_Connection=Yes

However, it generates the following error.

sqlalchemy.exc.DBAPIError: (Error) ('08001', '[08001] [Microsoft][ODBC SQL
Server Driver]Neither DSN nor SERVER keyword supplied (0)
(SQLDriverConnect)') None None

I think the URL is ncoded in SQL Alchmey, and I have tried the line below
as well:

sqlalchemy.url =
mssql+pyodbc:///?odbc_connect=DRIVER%3D%7BSQL+Server%7D%3BServer%3DServer%3BDatabase%3DDB%3BTrusted_Connection%3DYes

Which generates the error below:

"'%%' must be followed by '%%' or '(', found: %r" % (rest,))
ConfigParser.InterpolationSyntaxError: '%' must be followed by '%' or '(',
found:
'%3D%7BSQL+Server%7D%3BServer%3DServer%3BDatabase%3DDB%3BTrusted_Connection%3DYes;Trusted_Connection=Yes'

If anyone could please help me I would greatly appreciate it.

Thank you in advance :)

~Victor
--
You received this message because you are subscribed to the Google Groups "sqlalchemy-alembic" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy-alembic+***@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Michael Bayer
2013-06-13 23:44:23 UTC
Permalink
take a look here:

http://docs.sqlalchemy.org/en/rel_0_8/dialects/mssql.html#module-sqlalchemy.dialects.mssql.pyodbc
Hi,
I'm working through the Alembic tutorial and I have reached the point where I need to enter the DB URL (sqlalchemy.url).
The URL below (with the DSN py_test) works and I am able to run my migration, but I would like to connect without the DSN.
sqlalchemy.url = mssql+pyodbc://py_test; Trusted_Connection=Yes
sqlalchemy.url = mssql+pyodbc:///?odbc_connect=DRIVER={SQL Server};Server=Server;Database=DB;Trusted_Connection=Yes
However, it generates the following error.
sqlalchemy.exc.DBAPIError: (Error) ('08001', '[08001] [Microsoft][ODBC SQL Server Driver]Neither DSN nor SERVER keyword supplied (0) (SQLDriverConnect)') None None
sqlalchemy.url = mssql+pyodbc:///?odbc_connect=DRIVER%3D%7BSQL+Server%7D%3BServer%3DServer%3BDatabase%3DDB%3BTrusted_Connection%3DYes
"'%%' must be followed by '%%' or '(', found: %r" % (rest,)) ConfigParser.InterpolationSyntaxError: '%' must be followed by '%' or '(', found: '%3D%7BSQL+Server%7D%3BServer%3DServer%3BDatabase%3DDB%3BTrusted_Connection%3DYes;Trusted_Connection=Yes'
If anyone could please help me I would greatly appreciate it.
Thank you in advance :)
~Victor
--
You received this message because you are subscribed to the Google Groups "sqlalchemy-alembic" group.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "sqlalchemy-alembic" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy-alembic+***@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Victor Reichert
2013-06-14 00:32:51 UTC
Permalink
Is there a way for me to see what connection string Alembic is using? I
would have expected the encoded url to haved worked. Perhaps it is not
calling what I think it is.

Thank you for responding so quickly!

~Victor
Post by Michael Bayer
http://docs.sqlalchemy.org/en/rel_0_8/dialects/mssql.html#module-sqlalchemy.dialects.mssql.pyodbc
Hi,
I'm working through the Alembic tutorial and I have reached the point
where I need to enter the DB URL (sqlalchemy.url).
The URL below (with the DSN py_test) works and I am able to run my
migration, but I would like to connect without the DSN.
sqlalchemy.url = mssql+pyodbc://py_test; Trusted_Connection=Yes
sqlalchemy.url = mssql+pyodbc:///?odbc_connect=DRIVER={SQL
Server};Server=Server;Database=DB;Trusted_Connection=Yes
However, it generates the following error.
sqlalchemy.exc.DBAPIError: (Error) ('08001', '[08001] [Microsoft][ODBC SQL
Server Driver]Neither DSN nor SERVER keyword supplied (0)
(SQLDriverConnect)') None None
sqlalchemy.url = mssql+pyodbc:///?odbc_connect=
DRIVER%3D%7BSQL+Server%7D%3BServer%3DServer%3BDatabase%3DDB%3BTrusted_Connection%3DYes
"'%%' must be followed by '%%' or '(', found: %r" % (rest,))
ConfigParser.InterpolationSyntaxError: '%' must be followed by '%' or '(',
'%3D%7BSQL+Server%7D%3BServer%3DServer%3BDatabase%3DDB%3BTrusted_Connection%3DYes;Trusted_Connection=Yes'
If anyone could please help me I would greatly appreciate it.
Thank you in advance :)
~Victor
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy-alembic" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "sqlalchemy-alembic" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy-alembic+***@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Michael Bayer
2013-06-14 02:07:53 UTC
Permalink
funny I just gave this to someone last week. use this script to experiment with URLs:

from sqlalchemy.connectors import pyodbc
from sqlalchemy.engine.url import make_url

conn = pyodbc.PyODBCConnector()
url = make_url('mssql+pyodbc://DSN=py_test; Trusted_Connection=Yes')
connect_args = conn.create_connect_args(url)
print(connect_args)
Is there a way for me to see what connection string Alembic is using? I would have expected the encoded url to haved worked. Perhaps it is not calling what I think it is.
Thank you for responding so quickly!
~Victor
http://docs.sqlalchemy.org/en/rel_0_8/dialects/mssql.html#module-sqlalchemy.dialects.mssql.pyodbc
Hi,
I'm working through the Alembic tutorial and I have reached the point where I need to enter the DB URL (sqlalchemy.url).
The URL below (with the DSN py_test) works and I am able to run my migration, but I would like to connect without the DSN.
sqlalchemy.url = mssql+pyodbc://py_test; Trusted_Connection=Yes
sqlalchemy.url = mssql+pyodbc:///?odbc_connect=DRIVER={SQL Server};Server=Server;Database=DB;Trusted_Connection=Yes
However, it generates the following error.
sqlalchemy.exc.DBAPIError: (Error) ('08001', '[08001] [Microsoft][ODBC SQL Server Driver]Neither DSN nor SERVER keyword supplied (0) (SQLDriverConnect)') None None
sqlalchemy.url = mssql+pyodbc:///?odbc_connect=DRIVER%3D%7BSQL+Server%7D%3BServer%3DServer%3BDatabase%3DDB%3BTrusted_Connection%3DYes
"'%%' must be followed by '%%' or '(', found: %r" % (rest,)) ConfigParser.InterpolationSyntaxError: '%' must be followed by '%' or '(', found: '%3D%7BSQL+Server%7D%3BServer%3DServer%3BDatabase%3DDB%3BTrusted_Connection%3DYes;Trusted_Connection=Yes'
If anyone could please help me I would greatly appreciate it.
Thank you in advance :)
~Victor
--
You received this message because you are subscribed to the Google Groups "sqlalchemy-alembic" group.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "sqlalchemy-alembic" group.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "sqlalchemy-alembic" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy-alembic+***@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Victor Reichert
2013-06-14 16:52:30 UTC
Permalink
Unfortunately, that was me. I used the script you had given me to generate
the tests. I don't know why mssql+pyodbc:///?odbc_connect=DRIVER={SQL
Server};Server=Server;Database=DB;Trusted_Connection=Yes doesn't work in
Alembic as it does in SQL Alchmey. However, after reading through the code
I realized all I needed was mssql+pyodbc://@Server/DB. Initially I thought
I needed to specify Trusted_Connection=Yes (and I was jumping through some
hoops to do do so), but it defaults to it if the user name is not supplied.

Thank you again for your help,

~Victor
Post by Michael Bayer
from sqlalchemy.connectors import pyodbc
from sqlalchemy.engine.url import make_url
conn = pyodbc.PyODBCConnector()
url = make_url('mssql+pyodbc://DSN=py_test; Trusted_Connection=Yes')
connect_args = conn.create_connect_args(url)
print(connect_args)
Is there a way for me to see what connection string Alembic is using? I
would have expected the encoded url to haved worked. Perhaps it is not
calling what I think it is.
Thank you for responding so quickly!
~Victor
Post by Michael Bayer
http://docs.sqlalchemy.org/en/rel_0_8/dialects/mssql.html#module-sqlalchemy.dialects.mssql.pyodbc
Hi,
I'm working through the Alembic tutorial and I have reached the point
where I need to enter the DB URL (sqlalchemy.url).
The URL below (with the DSN py_test) works and I am able to run my
migration, but I would like to connect without the DSN.
sqlalchemy.url = mssql+pyodbc://py_test; Trusted_Connection=Yes
sqlalchemy.url = mssql+pyodbc:///?odbc_connect=DRIVER={SQL
Server};Server=Server;Database=DB;Trusted_Connection=Yes
However, it generates the following error.
sqlalchemy.exc.DBAPIError: (Error) ('08001', '[08001] [Microsoft][ODBC
SQL Server Driver]Neither DSN nor SERVER keyword supplied (0)
(SQLDriverConnect)') None None
sqlalchemy.url = mssql+pyodbc:///?odbc_connect=
DRIVER%3D%7BSQL+Server%7D%3BServer%3DServer%3BDatabase%3DDB%3BTrusted_Connection%3DYes
"'%%' must be followed by '%%' or '(', found: %r" % (rest,))
ConfigParser.InterpolationSyntaxError: '%' must be followed by '%' or '(',
'%3D%7BSQL+Server%7D%3BServer%3DServer%3BDatabase%3DDB%3BTrusted_Connection%3DYes;Trusted_Connection=Yes'
If anyone could please help me I would greatly appreciate it.
Thank you in advance :)
~Victor
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy-alembic" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy-alembic" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "sqlalchemy-alembic" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy-alembic+***@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Loading...