[sqlalchemy] Re: mssql and specifying a schema name?

2012-05-30 Thread Lukasz Szybalski


On May 30, 1:03 pm, Michael Bayer mike...@zzzcomputing.com wrote:
 the default schema name is determined by:

             SELECT default_schema_name FROM
             sys.database_principals
             WHERE name = (SELECT user_name())
             AND type = 'S'

 for some reason on your system it's coming up as MyDatabase.  You'd want to 
 fix that so that it comes up with dbo.

I can't.
The database was design for a specific application and I cannot make
changes to it structure, other then my records.

Is there a _somevalue that stores this in my engine, so that I can
overwrite it? or is it automatically get pulled every time I do a
autoload=True?

Thanks,
Lucas




 On May 30, 2012, at 1:52 PM, Lukasz Szybalski wrote:







  Hello,
  I'm trying to autolaod my table image but it keeps complaining that the 
  table doesn't exists.

  I've enabled the echo = true and I see that you specify in the query:

  SELECT [COLUMNS_1].[TABLE_SCHEMA], [COLUMNS_1].[TABLE_NAME], 
  [COLUMNS_1].[COLUMN_NAME], [COLUMNS_1].[IS_NULLABLE], 
  [COLUMNS_1].[DATA_TYPE], [COLUMNS_1].[ORDINAL_POSITION], 
  [COLUMNS_1].[CHARACTER_MAXIMUM_LENGTH], [COLUMNS_1].[NUMERIC_PRECISION], 
  [COLUMNS_1].[NUMERIC_SCALE], [COLUMNS_1].[COLUMN_DEFAULT], 
  [COLUMNS_1].[COLLATION_NAME]
  FROM [INFORMATION_SCHEMA].[COLUMNS] AS [COLUMNS_1]
  WHERE [COLUMNS_1].[TABLE_NAME] = ? AND [COLUMNS_1].[TABLE_SCHEMA] = ? ORDER 
  BY [COLUMNS_1].[ORDINAL_POSITION]
  INFO:sqlalchemy.engine.base.Engine:SELECT [COLUMNS_1].[TABLE_SCHEMA], 
  [COLUMNS_1].[TABLE_NAME], [COLUMNS_1].[COLUMN_NAME], 
  [COLUMNS_1].[IS_NULLABLE], [COLUMNS_1].[DATA_TYPE], 
  [COLUMNS_1].[ORDINAL_POSITION], [COLUMNS_1].[CHARACTER_MAXIMUM_LENGTH], 
  [COLUMNS_1].[NUMERIC_PRECISION], [COLUMNS_1].[NUMERIC_SCALE], 
  [COLUMNS_1].[COLUMN_DEFAULT], [COLUMNS_1].[COLLATION_NAME]
  FROM [INFORMATION_SCHEMA].[COLUMNS] AS [COLUMNS_1]
  WHERE [COLUMNS_1].[TABLE_NAME] = ? AND [COLUMNS_1].[TABLE_SCHEMA] = ? ORDER 
  BY [COLUMNS_1].[ORDINAL_POSITION]
  2012-05-30 12:39:06,193 INFO sqlalchemy.engine.base.Engine ('image', 
  'MyDatabase'
  )

  But my schema name is dbo?

  Where do I specify that?
  On create_engine?
  or?

  import sqlalchemy

  e = sqlalchemy.create_engine(mssql+pyodbc://Me:myPassword@SQLServer2008)

  #e.echo=True
  e.echo=False
  metadata=sqlalchemy.MetaData(e)

  from sqlalchemy.orm import sessionmaker
  Session = sessionmaker(bind=e, autoflush=True, autocommit=False)
  session = Session()

  from sqlalchemy.orm import mapper

  #---
  image_table = sqlalchemy.Table('image', metadata, autoload=True)

  ???Where do specify my schema dbo? so instead of sending 'image', 
  'MyDatabase'...you send 'image','dbo'?

  Thanks,
  Lucas

  --
  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 
  athttp://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 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.



[sqlalchemy] Re: mssql and specifying a schema name?

2012-05-30 Thread Lukasz Szybalski


On May 30, 1:03 pm, Michael Bayer mike...@zzzcomputing.com wrote:
 the default schema name is determined by:

             SELECT default_schema_name FROM
             sys.database_principals
             WHERE name = (SELECT user_name())
             AND type = 'S'

 for some reason on your system it's coming up as MyDatabase.  You'd want to 
 fix that so that it comes up with dbo.

Actually,
Let me try a different username.

That works. The username I was using was admin...so I logged in as
me and it has schema name of dbo.
Thanks,
Lucas




 On May 30, 2012, at 1:52 PM, Lukasz Szybalski wrote:







  Hello,
  I'm trying to autolaod my table image but it keeps complaining that the 
  table doesn't exists.

  I've enabled the echo = true and I see that you specify in the query:

  SELECT [COLUMNS_1].[TABLE_SCHEMA], [COLUMNS_1].[TABLE_NAME], 
  [COLUMNS_1].[COLUMN_NAME], [COLUMNS_1].[IS_NULLABLE], 
  [COLUMNS_1].[DATA_TYPE], [COLUMNS_1].[ORDINAL_POSITION], 
  [COLUMNS_1].[CHARACTER_MAXIMUM_LENGTH], [COLUMNS_1].[NUMERIC_PRECISION], 
  [COLUMNS_1].[NUMERIC_SCALE], [COLUMNS_1].[COLUMN_DEFAULT], 
  [COLUMNS_1].[COLLATION_NAME]
  FROM [INFORMATION_SCHEMA].[COLUMNS] AS [COLUMNS_1]
  WHERE [COLUMNS_1].[TABLE_NAME] = ? AND [COLUMNS_1].[TABLE_SCHEMA] = ? ORDER 
  BY [COLUMNS_1].[ORDINAL_POSITION]
  INFO:sqlalchemy.engine.base.Engine:SELECT [COLUMNS_1].[TABLE_SCHEMA], 
  [COLUMNS_1].[TABLE_NAME], [COLUMNS_1].[COLUMN_NAME], 
  [COLUMNS_1].[IS_NULLABLE], [COLUMNS_1].[DATA_TYPE], 
  [COLUMNS_1].[ORDINAL_POSITION], [COLUMNS_1].[CHARACTER_MAXIMUM_LENGTH], 
  [COLUMNS_1].[NUMERIC_PRECISION], [COLUMNS_1].[NUMERIC_SCALE], 
  [COLUMNS_1].[COLUMN_DEFAULT], [COLUMNS_1].[COLLATION_NAME]
  FROM [INFORMATION_SCHEMA].[COLUMNS] AS [COLUMNS_1]
  WHERE [COLUMNS_1].[TABLE_NAME] = ? AND [COLUMNS_1].[TABLE_SCHEMA] = ? ORDER 
  BY [COLUMNS_1].[ORDINAL_POSITION]
  2012-05-30 12:39:06,193 INFO sqlalchemy.engine.base.Engine ('image', 
  'MyDatabase'
  )

  But my schema name is dbo?

  Where do I specify that?
  On create_engine?
  or?

  import sqlalchemy

  e = sqlalchemy.create_engine(mssql+pyodbc://Me:myPassword@SQLServer2008)

  #e.echo=True
  e.echo=False
  metadata=sqlalchemy.MetaData(e)

  from sqlalchemy.orm import sessionmaker
  Session = sessionmaker(bind=e, autoflush=True, autocommit=False)
  session = Session()

  from sqlalchemy.orm import mapper

  #---
  image_table = sqlalchemy.Table('image', metadata, autoload=True)

  ???Where do specify my schema dbo? so instead of sending 'image', 
  'MyDatabase'...you send 'image','dbo'?

  Thanks,
  Lucas

  --
  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 
  athttp://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 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.



Re: [sqlalchemy] Re: mssql and specifying a schema name?

2012-05-30 Thread Michael Bayer

On May 30, 2012, at 3:24 PM, Lukasz Szybalski wrote:

 
 
 On May 30, 1:03 pm, Michael Bayer mike...@zzzcomputing.com wrote:
 the default schema name is determined by:
 
 SELECT default_schema_name FROM
 sys.database_principals
 WHERE name = (SELECT user_name())
 AND type = 'S'
 
 for some reason on your system it's coming up as MyDatabase.  You'd want 
 to fix that so that it comes up with dbo.
 
 I can't.
 The database was design for a specific application and I cannot make
 changes to it structure, other then my records.
 
 Is there a _somevalue that stores this in my engine, so that I can
 overwrite it? or is it automatically get pulled every time I do a
 autoload=True?

then you'd need to put schema='dbo' into each of your Table objects.   the 
autoload should work fine with that.



 
 Thanks,
 Lucas
 
 
 
 
 On May 30, 2012, at 1:52 PM, Lukasz Szybalski wrote:
 
 
 
 
 
 
 
 Hello,
 I'm trying to autolaod my table image but it keeps complaining that the 
 table doesn't exists.
 
 I've enabled the echo = true and I see that you specify in the query:
 
 SELECT [COLUMNS_1].[TABLE_SCHEMA], [COLUMNS_1].[TABLE_NAME], 
 [COLUMNS_1].[COLUMN_NAME], [COLUMNS_1].[IS_NULLABLE], 
 [COLUMNS_1].[DATA_TYPE], [COLUMNS_1].[ORDINAL_POSITION], 
 [COLUMNS_1].[CHARACTER_MAXIMUM_LENGTH], [COLUMNS_1].[NUMERIC_PRECISION], 
 [COLUMNS_1].[NUMERIC_SCALE], [COLUMNS_1].[COLUMN_DEFAULT], 
 [COLUMNS_1].[COLLATION_NAME]
 FROM [INFORMATION_SCHEMA].[COLUMNS] AS [COLUMNS_1]
 WHERE [COLUMNS_1].[TABLE_NAME] = ? AND [COLUMNS_1].[TABLE_SCHEMA] = ? ORDER 
 BY [COLUMNS_1].[ORDINAL_POSITION]
 INFO:sqlalchemy.engine.base.Engine:SELECT [COLUMNS_1].[TABLE_SCHEMA], 
 [COLUMNS_1].[TABLE_NAME], [COLUMNS_1].[COLUMN_NAME], 
 [COLUMNS_1].[IS_NULLABLE], [COLUMNS_1].[DATA_TYPE], 
 [COLUMNS_1].[ORDINAL_POSITION], [COLUMNS_1].[CHARACTER_MAXIMUM_LENGTH], 
 [COLUMNS_1].[NUMERIC_PRECISION], [COLUMNS_1].[NUMERIC_SCALE], 
 [COLUMNS_1].[COLUMN_DEFAULT], [COLUMNS_1].[COLLATION_NAME]
 FROM [INFORMATION_SCHEMA].[COLUMNS] AS [COLUMNS_1]
 WHERE [COLUMNS_1].[TABLE_NAME] = ? AND [COLUMNS_1].[TABLE_SCHEMA] = ? ORDER 
 BY [COLUMNS_1].[ORDINAL_POSITION]
 2012-05-30 12:39:06,193 INFO sqlalchemy.engine.base.Engine ('image', 
 'MyDatabase'
 )
 
 But my schema name is dbo?
 
 Where do I specify that?
 On create_engine?
 or?
 
 import sqlalchemy
 
 e = sqlalchemy.create_engine(mssql+pyodbc://Me:myPassword@SQLServer2008)
 
 #e.echo=True
 e.echo=False
 metadata=sqlalchemy.MetaData(e)
 
 from sqlalchemy.orm import sessionmaker
 Session = sessionmaker(bind=e, autoflush=True, autocommit=False)
 session = Session()
 
 from sqlalchemy.orm import mapper
 
 #---
 image_table = sqlalchemy.Table('image', metadata, autoload=True)
 
 ???Where do specify my schema dbo? so instead of sending 'image', 
 'MyDatabase'...you send 'image','dbo'?
 
 Thanks,
 Lucas
 
 --
 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 
 athttp://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 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.
 

-- 
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.



[sqlalchemy] Re: mssql and specifying a schema name?

2012-05-30 Thread Lukasz Szybalski


On May 30, 2:35 pm, Michael Bayer mike...@zzzcomputing.com wrote:
 On May 30, 2012, at 3:24 PM, Lukasz Szybalski wrote:











  On May 30, 1:03 pm, Michael Bayer mike...@zzzcomputing.com wrote:
  the default schema name is determined by:

              SELECT default_schema_name FROM
              sys.database_principals
              WHERE name = (SELECT user_name())
              AND type = 'S'

  for some reason on your system it's coming up as MyDatabase.  You'd want 
  to fix that so that it comes up with dbo.

  I can't.
  The database was design for a specific application and I cannot make
  changes to it structure, other then my records.

  Is there a _somevalue that stores this in my engine, so that I can
  overwrite it? or is it automatically get pulled every time I do a
  autoload=True?

 then you'd need to put schema='dbo' into each of your Table objects.   the 
 autoload should work fine with that.



Where would I put the schema='db'?

somewhere inside this statement ?
image_table = sqlalchemy.Table('image', metadata, autoload=True) ?

or?



[SQL Server]Login failed. The login is from an untrusted domain and
cannot be used with Windows authentication.









  Thanks,
  Lucas

  On May 30, 2012, at 1:52 PM, Lukasz Szybalski wrote:

  Hello,
  I'm trying to autolaod my table image but it keeps complaining that the 
  table doesn't exists.

  I've enabled the echo = true and I see that you specify in the query:

  SELECT [COLUMNS_1].[TABLE_SCHEMA], [COLUMNS_1].[TABLE_NAME], 
  [COLUMNS_1].[COLUMN_NAME], [COLUMNS_1].[IS_NULLABLE], 
  [COLUMNS_1].[DATA_TYPE], [COLUMNS_1].[ORDINAL_POSITION], 
  [COLUMNS_1].[CHARACTER_MAXIMUM_LENGTH], [COLUMNS_1].[NUMERIC_PRECISION], 
  [COLUMNS_1].[NUMERIC_SCALE], [COLUMNS_1].[COLUMN_DEFAULT], 
  [COLUMNS_1].[COLLATION_NAME]
  FROM [INFORMATION_SCHEMA].[COLUMNS] AS [COLUMNS_1]
  WHERE [COLUMNS_1].[TABLE_NAME] = ? AND [COLUMNS_1].[TABLE_SCHEMA] = ? 
  ORDER BY [COLUMNS_1].[ORDINAL_POSITION]
  INFO:sqlalchemy.engine.base.Engine:SELECT [COLUMNS_1].[TABLE_SCHEMA], 
  [COLUMNS_1].[TABLE_NAME], [COLUMNS_1].[COLUMN_NAME], 
  [COLUMNS_1].[IS_NULLABLE], [COLUMNS_1].[DATA_TYPE], 
  [COLUMNS_1].[ORDINAL_POSITION], [COLUMNS_1].[CHARACTER_MAXIMUM_LENGTH], 
  [COLUMNS_1].[NUMERIC_PRECISION], [COLUMNS_1].[NUMERIC_SCALE], 
  [COLUMNS_1].[COLUMN_DEFAULT], [COLUMNS_1].[COLLATION_NAME]
  FROM [INFORMATION_SCHEMA].[COLUMNS] AS [COLUMNS_1]
  WHERE [COLUMNS_1].[TABLE_NAME] = ? AND [COLUMNS_1].[TABLE_SCHEMA] = ? 
  ORDER BY [COLUMNS_1].[ORDINAL_POSITION]
  2012-05-30 12:39:06,193 INFO sqlalchemy.engine.base.Engine ('image', 
  'MyDatabase'
  )

  But my schema name is dbo?

  Where do I specify that?
  On create_engine?
  or?

  import sqlalchemy

  e = sqlalchemy.create_engine(mssql+pyodbc://Me:myPassword@SQLServer2008)

  #e.echo=True
  e.echo=False
  metadata=sqlalchemy.MetaData(e)

  from sqlalchemy.orm import sessionmaker
  Session = sessionmaker(bind=e, autoflush=True, autocommit=False)
  session = Session()

  from sqlalchemy.orm import mapper

  #---
  image_table = sqlalchemy.Table('image', metadata, autoload=True)

  ???Where do specify my schema dbo? so instead of sending 'image', 
  'MyDatabase'...you send 'image','dbo'?

-- 
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.



Re: [sqlalchemy] Re: mssql and specifying a schema name?

2012-05-30 Thread Michael Bayer

On May 30, 2012, at 3:56 PM, Lukasz Szybalski wrote:

 
 
 On May 30, 2:35 pm, Michael Bayer mike...@zzzcomputing.com wrote:
 On May 30, 2012, at 3:24 PM, Lukasz Szybalski wrote:
 
 
 
 
 
 
 
 
 
 
 
 On May 30, 1:03 pm, Michael Bayer mike...@zzzcomputing.com wrote:
 the default schema name is determined by:
 
 SELECT default_schema_name FROM
 sys.database_principals
 WHERE name = (SELECT user_name())
 AND type = 'S'
 
 for some reason on your system it's coming up as MyDatabase.  You'd want 
 to fix that so that it comes up with dbo.
 
 I can't.
 The database was design for a specific application and I cannot make
 changes to it structure, other then my records.
 
 Is there a _somevalue that stores this in my engine, so that I can
 overwrite it? or is it automatically get pulled every time I do a
 autoload=True?
 
 then you'd need to put schema='dbo' into each of your Table objects.   the 
 autoload should work fine with that.
 
 
 
 Where would I put the schema='db'?
 
 somewhere inside this statement ?
 image_table = sqlalchemy.Table('image', metadata, autoload=True) ?
 
 or?
 
 
 
 [SQL Server]Login failed. The login is from an untrusted domain and
 cannot be used with Windows authentication.

if you're already using a different username that solves the problem, stick 
with that.

otherwise yes, Table('image', metadata, schema='dbo', autoload=True)

using schema can make things more complicated so don't use it if you don't 
have to.


-- 
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.