Issue creating table in MS SQL Database with Python script
I think you need to add cnxn.commit()
command just before the cnxn.close()
. Thats how you save the changes made in the program to the database
Each user in MS SQL Server has a default schema associated with it. The configuration details depend on the version of SQL server and it is configured in the Enterprise Manager. I don't think SQL Management studio has GUI visibility into it.
You can try querying for it using:
select default_schema_name
, type_desc
, name
, create_date
from sys.database_principals
order by default_schema_name
, type_desc
, name
You can also explicitly create tables in a particular schema by prefixing schema name to the table name, i.e.
create myschema.mytable as...