Ive successfully connected mysql to Visual studio with the 'MySQL for visual studio' and 'Connector/Python' add ons. I am able to see my database connection in the server explorer and open tables within the database. However i am struggling to be able to make the connection within my written code (i need to run algorithms on the data). My inital idea was to create a dataframe with all the data and run algorthims on that. I ran the following code:
engine=create_engine('mssql+pyodbc://'+servername+'/'+database)
conn=engine.connect()
metadata=MetaData(conn)
tbl=Table(tablename,metadata,autoload=True,schema='dbo')
sql=tbl.select()
result=conn.execute(sql)
df=pd.DataFrame(database=list(result),columns=result.keys())
conn.close()
and received an sqlalchemy interface error- data source name not found and no default driver specified.
I also tried:
engine=sqlalchemy.create_engine('mysql+mysqlconnector://Localhost(databasename)/Table/new_event_data')
the_frame=pd.read_sql_query("SELECT * FROM %s;" %new_event_data, engine)
the_frame=pd.read_sql_table(new_event_data, engine)
which resulted in an error of 'new_event_data' is not specified.
There seems to be an issue making the connection between my code and the data. The full path for the data from the mysql database which was imported into visual studio is : DataExplorer://Localhost(databasename)/Table/new_event_data
Any tips on getting the data into a suitable format to access in ML algorthims? eg dataframe etc. Many thanks.
engine=create_engine('mssql+pyodbc://'+servername+'/'+database)
conn=engine.connect()
metadata=MetaData(conn)
tbl=Table(tablename,metadata,autoload=True,schema='dbo')
sql=tbl.select()
result=conn.execute(sql)
df=pd.DataFrame(database=list(result),columns=result.keys())
conn.close()
and received an sqlalchemy interface error- data source name not found and no default driver specified.
I also tried:
engine=sqlalchemy.create_engine('mysql+mysqlconnector://Localhost(databasename)/Table/new_event_data')
the_frame=pd.read_sql_query("SELECT * FROM %s;" %new_event_data, engine)
the_frame=pd.read_sql_table(new_event_data, engine)
which resulted in an error of 'new_event_data' is not specified.
There seems to be an issue making the connection between my code and the data. The full path for the data from the mysql database which was imported into visual studio is : DataExplorer://Localhost(databasename)/Table/new_event_data
Any tips on getting the data into a suitable format to access in ML algorthims? eg dataframe etc. Many thanks.