almarklein / itemdb Goto Github PK
View Code? Open in Web Editor NEWEasy transactional database for Python dicts, backed by SQLite
Home Page: https://itemdb.readthedocs.io
License: MIT License
Easy transactional database for Python dicts, backed by SQLite
Home Page: https://itemdb.readthedocs.io
License: MIT License
db = itemdb.ItemDB(dbname)
db.ensure_table("all","!videoid","status")
s_thread_fastlane
db.ensure_table("all","!videoid","status")
File "D:\Program Files\anaconda3\lib\site-packages\itemdb.py", line 211, in ensure_table
self._ensure_table_helper1(table_name, indices, missing_indices)
File "D:\Program Files\anaconda3\lib\site-packages\itemdb.py", line 217, in _ensure_table_helper1
self._ensure_table_helper2(table_name, indices)
File "D:\Program Files\anaconda3\lib\site-packages\itemdb.py", line 251, in _ensure_table_helper2
cur.execute(text)
sqlite3.OperationalError: near "all": syntax error
all seem to be keyword change to others fixed that
This creates an sqlite syntaxerror which feels rather cryptic. A stackoverflow thread suggests anything prefixed with "sqlite_" is forbidden, but anything else should work, as long as you enclose with quoted. Not sure if we do that.
Hey there @almarklein ๐๐ผ
When testing out timetagger on my workstation, which has an old version of SQLite3 (3.7.17 2013-05-20 00:56:22), it's failing to ensure the user table is created due to that version not supporting the WITHOUT ROWID command found in the "get_unsafe_webtoken" method call.
Just filing this issue to either get a fix in software or a list of minimum versions required for itemdb. The fix was just to update to a newer version of SQLite3.
Thanks!
same db and table with 6 records in it ,post_id is index post_link is not ,
db=context['db']
tables=db.get_table_names()
print('current operating db:',tables)
for t in tables:
list = db.select_all(t) # -> list of 2 items
# print('------',t,'---------',list)
if t=='scrape':
for i in list:
if i['post_link']==post_link:
print('-------------','table',t,'has record\n',i['post_id'])
print is all the result expected
option2
tablename ="scrape"
# print('check link exist',post_link,db.select(tablename, "post_link==?",post_link))
try:
count = len(db.select(tablename, "post_link==?",post_link))
if count>0:
print('found exising record',count,'--,',post_link)
records=db.select(tablename, "post_link==?",post_link)
for r in records:
print('!!!!!!!!!',r['post_id'])
return True
else:
return False
except:
return False
constanly say False.
am i mistaken?
what if i need to know by whether the same post_link is there
Although #10 should make users much more aware of SQL injections, here's another idea to help users prevent bad practice.
The most likely route for unsafe data to enter a database command, is via the query arg of e.g. select
or delete
. We could parse this argument and check that it only consists of simple names, logical operators ("AND" and "OR") and question marks, and perhaps some other syntax that I'm overlooking now.
We could then show a warning or even raise an exception (when a flag is certain set?) when things look unsafe.
This is just an idea for now.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.