In [1]:
import networkx as nx
import numpy as np
import matplotlib.pyplot as plt
import sqlite3
import pandas as pd


import state
import component

In [3]:
pwd


Out[3]:
'C:\\Users\\chaithcock\\Documents\\repos\\RushHour\\RushHourPy'

In [4]:
conn = sqlite3.connect('database\\rush_hour.db')
cur = conn.cursor()

In [5]:
sql = "select * from component c join comp_stats s on c.id = s.component_id"
comp_data_df = pd.read_sql(sql,conn)


---------------------------------------------------------------------------
OperationalError                          Traceback (most recent call last)
~\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\io\sql.py in execute(self, *args, **kwargs)
   1403             else:
-> 1404                 cur.execute(*args)
   1405             return cur

OperationalError: no such table: component

During handling of the above exception, another exception occurred:

DatabaseError                             Traceback (most recent call last)
<ipython-input-5-6c3076d258c0> in <module>()
      1 sql = "select * from component c join comp_stats s on c.id = s.component_id"
----> 2 comp_data_df = pd.read_sql(sql,conn)

~\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\io\sql.py in read_sql(sql, con, index_col, coerce_float, params, parse_dates, columns, chunksize)
    398             sql, index_col=index_col, params=params,
    399             coerce_float=coerce_float, parse_dates=parse_dates,
--> 400             chunksize=chunksize)
    401 
    402     try:

~\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\io\sql.py in read_query(self, sql, index_col, coerce_float, params, parse_dates, chunksize)
   1437 
   1438         args = _convert_params(sql, params)
-> 1439         cursor = self.execute(*args)
   1440         columns = [col_desc[0] for col_desc in cursor.description]
   1441 

~\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\io\sql.py in execute(self, *args, **kwargs)
   1414             ex = DatabaseError(
   1415                 "Execution failed on sql '%s': %s" % (args[0], exc))
-> 1416             raise_with_traceback(ex)
   1417 
   1418     @staticmethod

~\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\compat\__init__.py in raise_with_traceback(exc, traceback)
    342         if traceback == Ellipsis:
    343             _, _, traceback = sys.exc_info()
--> 344         raise exc.with_traceback(traceback)
    345 else:
    346     # this version of raise is a syntax error in Python 3

~\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\io\sql.py in execute(self, *args, **kwargs)
   1402                 cur.execute(*args, **kwargs)
   1403             else:
-> 1404                 cur.execute(*args)
   1405             return cur
   1406         except Exception as exc:

DatabaseError: Execution failed on sql 'select * from component c join comp_stats s on c.id = s.component_id': no such table: component

In [23]:
comp_data_df.head()


Out[23]:
id comb_class_id topo_class component_id num_states num_soln_states density is_solvable diameter min_cut_size
0 1 36 None 1 96 20 0.046053 1 14 -1
1 2 36 None 2 146 34 0.032593 1 14 -1
2 3 36 None 3 11 1 0.254545 1 6 -1
3 4 36 None 4 236 28 0.023440 1 14 -1
4 5 36 None 5 16 2 0.175000 1 7 -1

In [31]:
comp_data_df.diameter.max()


Out[31]:
35

In [22]:
#state_df = pd.read_sql("select * from state where comb_class_id = 36;",conn)
#component_df = pd.read_sql("select * from component where comb_class_id = 36;",conn)
#comp_edges_df = pd.read_sql("select * from comp_edges where comb_class_id = 36", conn)

In [14]:
state_df.head()


Out[14]:
red_car_end_a game_hash_top game_hash_bottom comb_class_id topo_class_hash is_soln_state component_id node_id soln_nbr_id soln_dist
0 12 2613951457693702 0 36 None NaN 956 1 None 7.0
1 12 2613558735048704 0 36 None NaN 957 1 None 4.0
2 12 2613541588733952 0 36 None NaN 957 4 None 4.0
3 12 2613539445444608 0 36 None NaN 957 10 None 4.0
4 12 2613539944569856 211106232532992 36 None NaN 958 1 None 6.0

In [ ]: