Comments (7)
I haven't used the DB-API directly myself. What would the integration look like?
from records.
Using the Sqlite standard lib is straightforward: here is some code I wrote while scraping Living Social for my wife. 😈 It is not the prettiest code out there, but it works... and a reason why a simple method to do this with Records will be highly requested.
# Start the DB
def init_db():
con = sqlite3.connect("Living_Social.db")
cur = con.cursor()
cur.execute(
'''CREATE TABLE IF NOT EXISTS deals (id INTEGER PRIMARY KEY, name TEXT, price_before REAL, price_after REAL, url TEXT UNIQUE, scrapetime text )''')
con.commit()
cur.close()
con.close()
def save_to_db(deal_info):
con = sqlite3.connect("Living_Social.db")
cur = con.cursor()
# Had to use OR IGNORE due scrape pulling down more than one listing
# Using the URL as the Unique identifier because it contains the deal ID and we need it anyway
cur.execute("INSERT OR IGNORE INTO deals (name, price_before, price_after, url, scrapetime) VALUES (?,?,?,?,?)", \
[deal_info['name'], deal_info['price_before'], deal_info['price_after'], deal_info['url'], deal_info['scrapetime']])
con.commit()
cur.close()
con.close()
As far as integration into records is concerned... no idea. 😕
from records.
You can simply check DATABASE_URL
string and use sqlite3.connect()
instead of psycopg2.connect()
.
from records.
It looks like the parameterization style is different. I'd have to take a closer look.
If we're going to support multiple databases, I think using SQLAlchemy as our driver would be the simplest choice.
from records.
Currently, this library plans to support Postgres–only. That may change, but not now.
from records.
cough support for sqlite has been added!
from records.
✨ 🍰 ✨
v0.4.0 includes support for all major databases. Enjoy!
from records.
Related Issues (20)
- RecordCollection support fetch many
- records.Database.query can't return affected rowcounts? HOT 1
- mssql query works for sqlalchemy but not for records HOT 1
- (sqlite3.ProgrammingError) Cannot operate on a closed database.
- Within transaction, the error disappeared
- database connections
- Can I get multiple sql command's output
- 导出excel无异常情况,但是无法生成xls文件 HOT 1
- can not read sqlserver! data can be read using sqlalchemy but records no! HOT 2
- MSSQL Queries are broken
- Is records being maintained? HOT 3
- How to get the last sql run
- Export XLS error HOT 1
- This library may no longer be maintained, and many problems 1 year ago have not been dealt with HOT 6
- records python3 is not compatible with new sqlalchemy release 1.4.0 HOT 7
- records (v0.5.3) is incompatible with latest Pandas (v1.2.4) cause they have requires different openpyxl version dependency, is there any way to fix this issue? HOT 2
- db.query('SELECT * FROM persons) can't execute
- Records is not compatible with Python 3.8+ HOT 1
- sqlalchemy 2.0 support. HOT 1
- How to connect to oracle?Can you give me a demo?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from records.