@@ -485,10 +485,12 @@ def read_sql(
485
485
486
486
Examples
487
487
--------
488
- Read data from SQL via either a SQL query or a SQL tablename (latter not
489
- possible for SQLite tables)
488
+ Read data from SQL via either a SQL query or a SQL tablename.
489
+ When using a SQLite database only SQL queries are accepted,
490
+ providing only the SQL tablename will result in an error.
491
+
490
492
>>> from sqlite3 import connect
491
- >>> conn = connect('file.db ')
493
+ >>> conn = connect(':memory: ')
492
494
>>> df = pd.DataFrame(data=[[0, '10/11/12'], [1, '12/11/10']],
493
495
... columns=['int_column', 'date_column'])
494
496
>>> df.to_sql('test_data', conn)
@@ -500,12 +502,12 @@ def read_sql(
500
502
501
503
>>> pd.read_sql('test_data', 'postgres:///db_name') # doctest:+SKIP
502
504
503
- Apply dateparsing to columns through the ``parse_dates`` argument
505
+ Apply date parsing to columns through the ``parse_dates`` argument
504
506
505
507
>>> pd.read_sql('SELECT int_column, date_column FROM test_data',
506
508
... conn,
507
509
... parse_dates=["date_column"])
508
- int_column date_column
510
+ int_column date_column
509
511
0 0 2012-10-11
510
512
1 1 2010-12-11
511
513
@@ -517,11 +519,11 @@ def read_sql(
517
519
>>> pd.read_sql('SELECT int_column, date_column FROM test_data',
518
520
... conn,
519
521
... parse_dates={"date_column": {"errors": "ignore"}})
520
- int_column date_column
522
+ int_column date_column
521
523
0 0 2012-10-11
522
524
1 1 2010-12-11
523
525
524
- 2. Apply a dayfirst dateparsing order on the values of "date_column"
526
+ 2. Apply a dayfirst date parsing order on the values of "date_column"
525
527
526
528
>>> pd.read_sql('SELECT int_column, date_column FROM test_data',
527
529
... conn,
@@ -530,12 +532,12 @@ def read_sql(
530
532
0 0 2012-11-10
531
533
1 1 2010-11-12
532
534
533
- 3. Apply custom formatting when dateparsing the values of "date_column"
535
+ 3. Apply custom formatting when date parsing the values of "date_column"
534
536
535
537
>>> pd.read_sql('SELECT int_column, date_column FROM test_data',
536
538
... conn,
537
539
... parse_dates={"date_column": {"format": "%d/%m/%y"}})
538
- int_column date_column
540
+ int_column date_column
539
541
0 0 2012-11-10
540
542
1 1 2010-11-12
541
543
"""
0 commit comments