Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
T
Twint
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
Twint
Commits
93c8d273
Commit
93c8d273
authored
May 28, 2018
by
Cody Zacharias
Committed by
GitHub
May 28, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.1.3 Update
parent
f93c3998
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
110 additions
and
31 deletions
+110
-31
twint/db.py
twint/db.py
+110
-31
No files found.
twint/db.py
View file @
93c8d273
import
datetime
from
datetime
import
datetime
import
sqlite3
import
sys
def
Conn
(
Database
):
if
Database
:
print
(
"[+] Inserting into Database: "
+
str
(
Database
))
conn
=
init
(
Database
)
if
isinstance
(
conn
,
str
):
print
(
str
)
sys
.
exit
(
1
)
else
:
conn
=
""
return
conn
def
init
(
db
):
try
:
...
...
@@ -23,52 +36,82 @@ def init(db):
link text,
retweet bool,
user_rt text,
mentions text
mentions text,
date_update text not null
);
"""
cursor
.
execute
(
table_tweets
)
table_
user
s
=
"""
table_
followers_name
s
=
"""
CREATE TABLE IF NOT EXISTS
user
s (
user text,
followers_name
s (
user text
not null
,
date_update text not null,
num_tweets integer
,
PRIMARY KEY (user,
date_update
)
follower text not null
,
PRIMARY KEY (user,
follower
)
);
"""
cursor
.
execute
(
table_
user
s
)
cursor
.
execute
(
table_
followers_name
s
)
table_
search
=
"""
table_
following_names
=
"""
CREATE TABLE IF NOT EXISTS
search
es (
user text,
following_nam
es (
user text
not null
,
date_update text not null,
num_tweets integer,
search_keyword text,
PRIMARY KEY (user, date_update, search_keyword)
follows text not null,
PRIMARY KEY (user, follows)
);
"""
cursor
.
execute
(
table_
search
)
cursor
.
execute
(
table_
following_names
)
table_followers
=
"""
CREATE TABLE IF NOT EXISTS
followers (
user text not null,
id integer not null,
name text,
username text not null,
bio text,
url text,
join_date text not null,
join_time text not null,
tweets integer,
following integer,
followers integer,
likes integer,
media integer,
private text not null,
verified text not null,
avatar text not null,
date_update text not null,
follower text not null,
PRIMARY KEY (
user
, follower)
PRIMARY KEY (
id, username
, follower)
);
"""
cursor
.
execute
(
table_followers
)
table_following
=
"""
CREATE TABLE IF NOT EXISTS
following (
user text not null,
id integer not null,
name text,
username text not null,
bio text,
location text,
url text,
join_date text not null,
join_time text not null,
tweets integer,
following integer,
followers integer,
likes integer,
media integer,
private text not null,
verified text not null,
avatar text not null,
date_update text not null,
follows text not null,
PRIMARY KEY (
user
, follows)
PRIMARY KEY (
id, username
, follows)
);
"""
cursor
.
execute
(
table_following
)
...
...
@@ -77,28 +120,64 @@ def init(db):
except
Exception
as
e
:
return
str
(
e
)
def
following
(
conn
,
user
,
follow
):
def
fTable
(
Followers
):
if
Followers
:
table
=
"followers_names"
else
:
table
=
"following_names"
return
table
def
uTable
(
Followers
):
if
Followers
:
table
=
"followers"
else
:
table
=
"following"
return
table
def
follow
(
conn
,
Username
,
Followers
,
User
):
try
:
date_time
=
str
(
datetime
.
datetime
.
now
())
date_time
=
str
(
datetime
.
now
())
cursor
=
conn
.
cursor
()
entry
=
(
user
,
date_time
,
follow
,)
cursor
.
execute
(
'INSERT INTO following VALUES(?,?,?)'
,
entry
)
entry
=
(
User
,
date_time
,
Username
,)
query
=
'INSERT INTO {} VALUES(?,?,?)'
.
format
(
fTable
(
Followers
))
cursor
.
execute
(
query
,
entry
)
conn
.
commit
()
except
sqlite3
.
IntegrityError
:
pass
def
followers
(
conn
,
user
,
follow
):
def
user
(
conn
,
Username
,
Followers
,
User
):
try
:
date_time
=
str
(
datetime
.
datetime
.
now
())
date_time
=
str
(
datetime
.
now
())
cursor
=
conn
.
cursor
()
entry
=
(
user
,
date_time
,
follow
,)
cursor
.
execute
(
'INSERT INTO followers VALUES(?,?,?)'
,
entry
)
entry
=
(
User
.
id
,
User
.
name
,
User
.
username
,
User
.
bio
,
User
.
location
,
User
.
url
,
User
.
join_date
,
User
.
join_time
,
User
.
tweets
,
User
.
following
,
User
.
followers
,
User
.
likes
,
User
.
media_count
,
User
.
is_private
,
User
.
is_verified
,
User
.
avatar
,
date_time
,
Username
,)
query
=
'INSERT INTO {} VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)'
.
format
(
uTable
(
Followers
))
cursor
.
execute
(
query
,
entry
)
conn
.
commit
()
except
sqlite3
.
IntegrityError
:
pass
def
tweets
(
conn
,
Tweet
):
try
:
date_time
=
str
(
datetime
.
now
())
cursor
=
conn
.
cursor
()
entry
=
(
Tweet
.
id
,
Tweet
.
user_id
,
...
...
@@ -108,14 +187,14 @@ def tweets(conn, Tweet):
Tweet
.
location
,
Tweet
.
username
,
Tweet
.
tweet
,
Tweet
.
replies
,
Tweet
.
likes
,
Tweet
.
retweets
,
","
.
join
(
Tweet
.
hashtags
),
Tweet
.
link
,
Tweet
.
is_
retweet
,
Tweet
.
retweet
,
Tweet
.
user_rt
,
","
.
join
(
Tweet
.
mentions
))
","
.
join
(
Tweet
.
mentions
),
date_time
,)
cursor
.
execute
(
'INSERT INTO tweets VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)'
,
entry
)
conn
.
commit
()
except
sqlite3
.
IntegrityError
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment