r@localhost:5432/mydatabase")
    
    engine = create_engine("mysql+mysqldb://scott:tiger@localhost/foo")
    
    engine = create_engine("oracle://scott:[[email protected]](/cdn-cgi/l/email-protection):1521/sidname")
    
    engine = create_engine("mssql+pyodbc://mydsn")
    
    # sqlite://<nohostname>/<path>
    # where <path> is relative:
    engine = create_engine("sqlite:///foo.db")
    
    # or absolute, starting with a slash:
    engine = create_engine("sqlite:////absolute/path/to/foo.db")
    

For more information see the examples the SQLAlchemy [ documentation
](https://docs.sqlalchemy.org/en/latest/core/engines.html)

###  Advanced SQLAlchemy queries  #

You can use SQLAlchemy constructs to describe your query.

Use ` sqlalchemy.text()  ` to specify query parameters in a backend-neutral
way

    
    
    In [659]: import sqlalchemy as sa
    
    In [660]: pd.read_sql(
       .....:     sa.text("SELECT * FROM data where Col_1=:col1"), engine, params={"col1": "X"}
       .....: )
       .....: 
    Out[660]: 
       index  id                        Date Col_1  Col_2  Col_3
    0      0  26  2010-10-18 00:00:00.000000     X   27.5      1
    

If you have an SQLAlchemy description of your database you can express where
conditions using SQLAlchemy expressions

    
    
    In [661]: metadata = sa.MetaData()
    
    In [662]: data_table = sa.Table(
       .....:     "data",
       .....:     metadata,
       .....:     sa.Column("index", sa.Integer),
       .....:     sa.Column("Date", sa.DateTime),
       .....:     sa.Column("Col_1", sa.String),
       .....:     sa.Column("Col_2", sa.Float),
       .....:     sa.Column("Col_3", sa.Boolean),
       .....: )
       .....: 
    
    In [663]: pd.read_sql(sa.select(data_table).where(data_table.c.Col_3 is True), engine)
    Out[663]: 
    Empty DataFrame
    Columns: [index, Date, Col_1, Col_2, Col_3]
    Index: []
    

You can combine SQLAlchemy expressions with parameters passed to [ `
read_sql()  ` ](../reference/api/pandas.read_sql.html#pandas.read_sql
"pandas.read_sql") using ` sqlalchemy.bindparam()  `

    
    
    In [664]: import datetime as dt
    
    In [665]: expr = sa.select(data_table).where(data_table.c.Date > sa.bindparam("date"))
    
    In [666]: pd.read_sql(expr, engine, params={"date": dt.datetime(2010, 10, 18)})
    Out[666]: 
       index       Date Col_1  Col_2  Col_3
    0      1 2010-10-19     Y -12.50  False
    1      2 2010-10-20     Z   5.73   True
    

###  Sqlite fallback  #

The use of sqlite is supported without using SQLAlchemy. This mode requires a
Python database adapter which respect the [ Python DB-API
](https://www.python.org/dev/peps/pep-0249/) .

You can create connections like so:

    
    
    import sqlite3
    
    con = sqlite3.connect(":memory:")
    

And then issue the following queries:

    
    
    data.to_sql("data", con)
    pd.read_sql_query("SELECT * FROM data", con)
    

##  Google BigQuery  #

The ` pandas-gbq  ` package provides functionality to read/write from Google
BigQuery.

pandas integrates with this external package. if ` pandas-gbq  ` is installed,
you can use the pandas methods ` pd.read_gbq  ` and ` DataFrame.to_gbq  ` ,
which will call the respective functions from ` pandas-gbq  ` .

Full documentation can be found [ here ](https://pandas-
gbq.readthedocs.io/en/latest/) .

##  Stata format  #

###  Writing to stata format  #

The method ` DataFrame.to_stata()  ` will write a DataFrame into a .dta file.
The format version of this file is always 115 (Stata 12).

    
    
    In [667]: df = pd.DataFrame(np.random.randn(10, 2), columns=list("AB"))
    
    In [668]: df.to_stata("stata.dta")
    

_Stata_ data files have limited data type support; only strings with 244 or
fewer characters, ` int8  ` , ` int16  ` , ` int32  ` , ` float32  ` and `
float64  ` can be stored in ` .dta  ` files. Additionally, _Stata_ reserves
certain values to represent missing data. Exporting a non-missing value t