I have a simple script to pull the table names in a given database from sql 
server.

import sqlalchemy

def GetConn(Server, Database):
    engine = sqlalchemy.create_engine("mssql+pyodbc://"+Server+"/"+Database+
"?driver=SQL+Server+Native+Client+10.0")
    return(engine)

def GetTableNames(Server, Database):
    engine = GetConn(Server, Database)
    table_names = engine.table_names()
    
    return(table_names)  

For a given server and database this script will return the list of table 
names. However, that same server and another database (lets call it x) 
returns an empty string.
I know for a fact that the database is not empty, and contains many tables.

Has anyone ran into a similar problem?

P.S. - This issue arose after I attempted to write a data frame to this 
same database. That snippet of code is:
df.to_sql('db_table2', engine, if_exists='replace')

Prior to attempting to write to sql, the first block of code ran perfectly.

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to