
Safe parameterization: Database.query('life=:everything', everything=42). $DATABASE_URL environment variable support.Ĭonvenience Database.get_table_names method.Ĭommand-line records tool for exporting queries. Iterated rows are cached for future reference. Other options include rows.as_dict() and rows.as_dict(ordered=True). If you’re only expecting one result: > rows. Or store a copy of your record collection for later reference: > rows.

Values can be accessed many ways: row.user_email, row, or row.įields with non-alphanumeric characters (like spaces) are also fully supported. Or iterate over them: for r in rows : print ( r. query ( 'select * from active_users' ) # or db.query_file('sqls/active-users.sql') We know how to write SQL, so let’s send some to our database: import records db = records. Your support helps tremendously with sustainability of motivation, as Open Source is no longer part of my day job.

If you’re interested in financially supporting Kenneth Reitz open source, consider visiting this link. While providing an elegant interface to work with your query results.ĭatabase support includes RedShift, Postgres, MySQL, SQLite, Oracle, and MS-SQL (drivers not included). This library strives to make this workflow as simple as possible, Surprisingly difficult with the standard tools available. Records is a very simple, but powerful, library for making raw SQL queries
